unity, asset operations
//----create asset
//ref: http://wiki.unity3d.com/index.php?title=CreateScriptableObjectAsset
CmyScriptableObject asset = ScriptableObject.CreateInstance<CmyScriptableObject> ();
AssetDatabase.CreateAsset (asset, path);
AssetDatabase.SaveAssets ();
AssetDatabase.Refresh();
EditorUtility.FocusProjectWindow ();
Selection.activeObject = asset;
//注:CmyScriptableObject类型最好单独定义在CmyScriptableObject.cs文件里,以保证所生成的asset文件的Script成员为非空。
//----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);
//save
AssetDatabase.SaveAssets();
//----get subasset of certain class type
CmyScriptableObject obj = AssetDatabase.LoadAssetAtPath<CmyScriptableObject> (path);
//----get all objects(sub assets) from assets
//ref: http://answers.unity3d.com/questions/1066162/how-do-i-return-the-path-of-a-sub-asset-in-an-asse.html
//suppose asset have objects(sub assets) attached to it
UnityEngine.Object[] allassets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(asset));
int assetCount=allassets.Length;
Debug.Log("assetCount:"+assetCount);
for(int i=0;i<assetCount;i++){
UnityEngine.Object _asset=allassets[i];
Debug.Log(_asset.name);
}
//----save asset
//if only want save the specified asset, use:
EditorUtility.SetDirty (asset);
//if want save all assets, use:
//----rename asset
string errorMessage=AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(asset),"new name");
if(errorMessage.Length==0){
Debug.Log("rename asset succ");
}else{
Debug.Log("rename asset failed: "+errorMessage);
}
//----rename subasset
CmyScriptableObject subAsset = AssetDatabase.LoadAssetAtPath<CmyScriptableObject> (AssetDatabase.GetAssetPath(asset));
subAsset.name = "new name";
//----hide subasset in Assets folder
//ref: http://answers.unity3d.com/questions/210726/how-to-hide-files-in-project-directory.html
CmyScriptableObject subAsset = AssetDatabase.LoadAssetAtPath<CmyScriptableObject> (AssetDatabase.GetAssetPath(asset));
subAsset.hideFlags = HideFlags.HideInHierarchy;
unity, asset operations的更多相关文章
- [Unity Asset]AssetBundle系列——游戏资源打包
转载:http://www.cnblogs.com/sifenkesi/p/3557231.html 将本地资源打包,然后放到资源服务器上供游戏客户端下载或更新.服务器上包含以下资源列表:(1)游戏内 ...
- Unity的Asset Store商店下载文件路径
如果之前在Asset Store商店下载过资源包,结果下次用的时候找不到了,不用急,其实Unity把它自动保到下面这个目录了,最后一个文件夹名与版本号有关,找到前面的即可. C:\Users\Admi ...
- Unity资源商店 Asset store下载文件夹的位置
Win10 C:\Users\用户名\AppData\Roaming\Unity\Asset Store-5.x\ Mac OS X ~/Library/Unity/Asset Store
- unity文件解析以及版本控制
刚开始使用unity做开发时,拿到一个范例工程先上传SVN,之后再自己做一些修改后,发现有非常多文件都有变化,这才知道有很多本地生成的文件,是不用上传的,但是不知道哪些才是需要共用的.之后又困扰于修改 ...
- Unity将来时:IL2CPP是什么?
作者:小玉链接:https://zhuanlan.zhihu.com/p/19972689来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. Unity3D 想必大家都不陌 ...
- HoloLens开发手记 - Unity development overview 使用Unity开发概述
Unity Technical Preview for HoloLens最新发行版为:Beta 24,发布于 09/07/2016 开始使用Unity开发HoloLens应用之前,确保你已经安装好了必 ...
- 【教程】Asset Server(联合开发)
Unity Asset Server下载 https://unity3d.com/cn/unity/team-license http://tieba.baidu.com/p/2419391804 W ...
- unity3d asset store下载的代码所在位置
Asset Store下载了官方的示例,却找不到了,又不想重新下载 PC:C:\Users\PCNAME\AppData\Roaming\Unity\Asset StoreMAC:"~/Li ...
- unity3d中asset store 的资源下载到本地的目录位置
来源:http://blog.csdn.net/fzhlee/article/details/8613688 C:/Users/[当前用户]/AppData/Roaming/Unity/Asset S ...
随机推荐
- mysql sql长度限制解决
mysql sql长度限制解决 今天发现了一个错误: Could not execute JDBC batch update 最后发现原因是SQL语句长度大于1M,而我机器上的mysql是 ...
- svn 冲突
转载:http://blog.sina.com.cn/s/blog_65fd4c1e0100h2cg.html 1. 如何产生冲突 当开发人员A和开发人员B从版本库同时检出文档1.txt,而A和B同 ...
- 【资料】wod烟草
注意: 1. 所有效果持续时间是整个地城 2. 某几样菸草在使用 烟雾的祝福 的时候效果只有LV1 (技能 -25), 表示该物品设计上主要是自己使用而非加给团队. SL = 技能等级 HL = 英雄 ...
- Unity 国际化 多语言设置
很多游戏中都有语言设置选项,NGUI插件中自带了国际化脚本,但是灵活性较低,而且目前项目是UGUI,以下是修改后,以便记录. Localization和NGUI中用法一样,挂在在一个不销毁的游戏物体上 ...
- 资源合并fis-postpackager-simple插件的使用
FIS默认只会进行文件打包,不会对页面中的静态资源引用进行替换,这时可以利用fis-postpackager-simple插件进行资源替换. 安装: npm install -g fis-postpa ...
- python接口自动化23-token参数关联登录(登录拉勾网)
前言 登录网站的时候,经常会遇到传token参数,token关联并不难,难的是找出服务器第一次返回token的值所在的位置,取出来后就可以动态关联了 登录拉勾网 1.先找到登录首页https://pa ...
- Lua中的元表和元方法
Lua中每个值都可具有元表. 元表是普通的Lua表,定义了原始值在某些特定操作下的行为.你可通过在值的原表中设置特定的字段来改变作用于该值的操作的某些行为特征.例如,当数字值作为加法的操作数时,Lua ...
- 魅族MX4的线控电路图
- json-lib 的maven dependency
项目中要用到json-lib,mvnrepository.com查找它的dependency时结果如下: <dependency> <groupId>net.sf.json-l ...
- 分别用Java和JS读取Properties文件内容
项目中经常用到的配置文件,除了XML文件之外,还会用到Properties文件来存储一些信息,例如国际化的设置.jdbc连接信息的配置等.有时候也会把一些路径或者sql语句放到Properties中, ...