首页 > 编程语言 > 详细

unity, add object to asset and remove object from asset

时间:2016-01-03 02:34:28      阅读:545      评论:0      收藏:0      [点我收藏+]

//----create a scriptable object and add it to an existing asset
                    CmyScriptableObject obj = ScriptableObject.CreateInstance<CmyScriptableObject> ();
                    AssetDatabase.AddObjectToAsset(obj,existingAsset);

                    // Reimport the asset after adding an object.
                    // Otherwise the change only shows up when saving the project
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(obj));


                    Selection.activeObject = obj;

 

//----remove object in asset

//ref : http://answers.unity3d.com/questions/219465/how-can-i-remove-an-object-from-an-asset.html

                    UnityEngine.Object.DestroyImmediate(obj, true);
                    AssetDatabase.SaveAssets();

unity, add object to asset and remove object from asset

原文:http://www.cnblogs.com/wantnon/p/5095651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!