Unity AssetBundle打包
来源:互联网 发布:mihoyo米哈游淘宝店铺 编辑:程序博客网 时间:2024/05/22 13:19
Unity AssetBundle打包
using UnityEngine;using UnityEditor;using System.IO;using System.Collections;public class ExportAssetBundle{ [MenuItem("AssetBundle/ExportAllAssetBundlePC")] static void DoExportAssetBundle() { //在测试情况下可能会频繁的打包生成Assetbundle,如果忘记改版本号的话可能会读取之前的缓存,可能就会看不到新的效果,所以先清一下缓存。 Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/PC"; if(!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] obj=Selection.GetFiltered(typeof(Object),SelectionMode.DeepAssets); foreach(Object _obj in obj) { Debug.Log("Create AssetBundle Name:"+_obj.name); } if (BuildPipeline.BuildAssetBundle(null, obj, pathAssetURL + "/all.assetbundle",BuildAssetBundleOptions.CollectDependencies| BuildAssetBundleOptions.CompleteAssets,BuildTarget.StandaloneWindows)) { AssetDatabase.Refresh(); Debug.Log("OK!"); } else { Debug.Log("Something Error!"); } } [MenuItem("AssetBundle/ExportSeparatedAssetBundlePC")] static void DoExportSeparatedAssetBundle() { Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/PC"; if (!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] Obj = Selection.GetFiltered(typeof(Object),SelectionMode.DeepAssets); foreach(Object _obj in Obj) { if (BuildPipeline.BuildAssetBundle(_obj, null, pathAssetURL +"/"+ _obj.name + ".assetbundle", BuildAssetBundleOptions.CollectDependencies)) { Debug.Log("OK!"); } else { Debug.Log(_obj.name+"Error!"); } } AssetDatabase.Refresh(); } [MenuItem("AssetBundle/ExportAllAssetBundleAndroid")] static void DoExportAssetBundleAndroid() { Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/Android"; if (!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] obj = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object _obj in obj) { Debug.Log("Create AssetBundle Name:" + _obj.name); } if (BuildPipeline.BuildAssetBundle(null, obj, pathAssetURL + "/all.assetbundle", BuildAssetBundleOptions.CollectDependencies,BuildTarget.Android)) { AssetDatabase.Refresh(); Debug.Log("OK!"); } else { Debug.Log("Something Error!"); } } [MenuItem("AssetBundle/ExportSeparatedAssetBundleAndroid")] static void DoExportSeparatedAssetBundleAndroid() { Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/Android"; if (!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] Obj = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object _obj in Obj) { if (BuildPipeline.BuildAssetBundle(_obj, null, pathAssetURL +"/"+ _obj.name + ".assetbundle", BuildAssetBundleOptions.CollectDependencies,BuildTarget.Android)) { Debug.Log("OK!"); } else { Debug.Log(_obj.name + "Error!"); } } AssetDatabase.Refresh(); } [MenuItem("AssetBundle/ExportAllAssetBundleIOS")] static void DoExportAssetBundleIOS() { Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/IOS"; if (!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] obj = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object _obj in obj) { Debug.Log("Create AssetBundle Name:" + _obj.name); } if (BuildPipeline.BuildAssetBundle(null, obj, pathAssetURL + "/all.assetbundle", BuildAssetBundleOptions.CollectDependencies, BuildTarget.iPhone)) { AssetDatabase.Refresh(); Debug.Log("OK!"); } else { Debug.Log("Something Error!"); } } [MenuItem("AssetBundle/ExportSeparatedAssetBundleIOS")] static void DoExportSeparatedAssetBundleIOS() { Caching.CleanCache(); string pathAssetURL = Application.dataPath + "/StreamingAssets/IOS"; if (!Directory.Exists(pathAssetURL)) { Directory.CreateDirectory(pathAssetURL); } Object[] Obj = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach (Object _obj in Obj) { if (BuildPipeline.BuildAssetBundle(_obj, null, pathAssetURL + "/" + _obj.name + ".assetbundle", BuildAssetBundleOptions.CollectDependencies, BuildTarget.iPhone)) { Debug.Log("OK!"); } else { Debug.Log(_obj.name + "Error!"); } } //BuildAssetBundleOptions.CollectDependencies(收集依赖关系):包含所有的依赖关系。 //BuildAssetBundleOptions.CompleteAssets(完整资源):强制包含整个资源。 //BuildAssetBundleOptions.DisableWriteTypeTree(禁用写入类型树):在资源包中不包含类型信息。 //BuildAssetBundleOptions.DeterministicAssetBundle(确定资源包):编译资源包使用一个哈希表储存对象ID在资源包中。 //BuildAssetBundleOptions.UncompressedAssetBundle(不压缩) AssetDatabase.Refresh(); }}
阅读全文
0 0
- Unity 资源打包Assetbundle
- Unity 资源打包Assetbundle
- Unity 资源打包Assetbundle
- Unity资源打包Assetbundle
- [Unity]AssetBundle打包策略
- Unity AssetBundle打包
- Unity资源打包之Assetbundle
- Unity之资源打包Assetbundle
- unity assetBundle更新 打包变化
- Unity资源打包之Assetbundle
- unity AssetBundle打包以及加载
- Unity AssetBundle 打包爬坑
- unity Editor 下Assetbundle 打包
- Unity手游:资源打包Assetbundle
- 关于在Unity中打包AssetBundle文件
- [Unity基础]打包与读取AssetBundle
- Unity AssetBundle资源打包,Depend依赖关系
- Unity之Assetbundle打包记录一
- BZOJ 1996: [Hnoi2010]chorus 合唱队 区间dp
- strncpy函数
- GIT命令大全
- spring boot 学习系列教程
- 传智播客长沙校区解读Java三大特点
- Unity AssetBundle打包
- 算法系列——Palindrome Number
- 专利查询官网
- 高考落榜学JAVA怎么样?
- unity foreach 中产生GC的问题
- Nginx + Laravel5 开发 页面缓存问题缓存问题。
- 三维重建过程与算法介绍
- HDU
- Android中的WebView达到一种web端可以运行app端代码的高度