资源打包Assetbundle
来源:互联网 发布:美图还原软件 编辑:程序博客网 时间:2024/06/05 07:02
在开发的过程中,我们需要加载外部资源,将先将资源打包为*.assetbundle文件,然后程序中可以之间使用。
- 打包Assetbundle
/// <summary> /// 将选中的预制分别打包 /// </summary> [MenuItem("DevTools/Build AssetBundles")] static void CreateAssetBundleThemelves() { // 获取要打包的对象(在Project视图中) Object[] selects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); // 遍历选中的对象 foreach (Object obj in selects) { // 文件的后缀名是assetbundle和unity都可以 string targetPath = Application.dataPath + "/StreamingAssets/" + obj.name + ".assetbundle"; BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies); } // 刷新编辑器(不写的话要手动刷新,否则打包的资源不能及时在Project视图内显示) AssetDatabase.Refresh(); }
DevTools/Build AssetBundles会出现在Unity3d的菜单中,如下:
- 加载AssetBundle
WWW www = new WWW("file://" + url); // 上面导出的是什么类型,这里对应的就是什么类型。 GameObject prefab = (GameObject)www.assetBundle.mainAsset; www.assetBundle.Unload(false); // 创建预制体 GameObject obj = (GameObject)Instantiate(prefab, positon, rotation);
写的简单,有不清楚的可以随时交流、学习。
0 0
- Unity 资源打包Assetbundle
- 资源打包Assetbundle
- AssetBundle打包资源
- 资源打包Assetbundle
- Unity 资源打包Assetbundle
- Unity 资源打包Assetbundle
- Unity3D-资源打包AssetBundle
- Unity资源打包Assetbundle
- 资源打包Assetbundle
- AssetBundle资源打包
- 资源打包Assetbundle
- [资源]AssetBundle打包
- AssetBundle------ 资源打包和依赖资源打包
- Unity资源打包之Assetbundle
- Unity之资源打包Assetbundle
- unity5.0资源打包AssetBundle
- Unity3d之资源打包Assetbundle
- Unity资源打包之Assetbundle
- nodejs Java SSH Git ADB 全局配置
- Spring的AOP配置
- 设计模式--适配器模式
- HDU1257 最长递增公共子序列问题
- 动态规划算法常见题型
- 资源打包Assetbundle
- netsdk、playsdk
- Error: Your project contains C++ files but it is not using a supported native build system
- bzoj 2257: [Jsoi2009]瓶子和燃料 (gcd+map)
- Javascript 将阿拉伯数字转换成罗马数字
- Unicode(UTF-8, UTF-16)令人混淆的概念
- PAT题型分类 & 跟着《算法笔记》撸PAT的记录汇总
- Java多线程:用三个线程控制循环输出10次ABC
- opencv之GrabCut函数使用和源码解读