码迷,mamicode.com
首页 > 编程语言 > 详细

unity, add object to asset and remove object from asset

时间:2016-01-03 02:36:42      阅读:667      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!