AssetBundles相关的坑
来源:互联网 发布:淘宝卖家无需物流发货 编辑:程序博客网 时间:2024/06/06 12:34
1.加载资源的时候一定要是用相对路径,即前面加上“file://” 如下所示
string path ="file://"+ Application.dataPath + "/output/" + assetBundleName;
2.重新打包后去加载资源要把之前的缓存清除掉。如下:
void Awake() { Caching.CleanCache(); }
3.1中的path要放在方法中,Application.dataPath不能全局变量中使用
4.AssetBundles在安卓和苹果下的打包需要加参数BuildTarget.Android和BuildTarget.iOS。
5.根据不同平台打包的方便代码
BuildPipeline.BuildAssetBundles (outputPath, BuildAssetBundleOptions.None,
EditorUserBuildSettings.activeBuildTarget);
6.不知道怎么回事打包到安卓上总是读取不到,试了好多遍,也许就是路径的问题的,附上一个经过多次测试没有问题的代码。再次强调路径、路径、路径。重要的事情说三遍。
public class Build : MonoBehaviour {[MenuItem("AB/CreatAssetBundles")] public static void Creat() { Caching.CleanCache(); string path=Path.Combine(Application.streamingAssetsPath, "Android"); if(!File.Exists(path)) { Directory.CreateDirectory(path); } BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.Android); AssetDatabase.Refresh(); }}
public class Load : MonoBehaviour{ string path; void Awake() { if(Application.platform==RuntimePlatform.Android) { path = "jar:file://" + Application.dataPath + "!/assets/Android/tex"; } else if(Application.platform==RuntimePlatform.WindowsEditor||Application.platform==RuntimePlatform.WindowsPlayer) { path = "file://" + Application.dataPath + "/StreamingAssets/Android/tex"; } }IEnumerator Start() { WWW www = WWW.LoadFromCacheOrDownload(path, 1); yield return www; AssetBundle ab = www.assetBundle; GetComponent<Image>().sprite = ab.LoadAsset<Sprite>("texture"); GameObject go = ab.LoadAsset<GameObject>("cube"); Instantiate(go); ab.Unload(false); }}
0 0
- AssetBundles相关的坑
- [Unity3D]AssetBundles的使用
- 【Unity3D自学记录】AssetBundles的使用
- Unity5.4 Assetbundles官方说明四(AssetBundles的下载和加载)
- Unity5.4 Assetbundles官方说明五(从AssetBundles的加载和卸载资源对象)
- 进击的AssetBundles和它的工具们
- Building AssetBundles
- unity AssetBundles
- Unity5.4 Assetbundles十一:遇到的坑和整理的打包和加载流程(资源包更新的简易框架)
- Unity手册AssetBundles第一篇AssetBundles
- Unity5.4 Assetbundles官方说明三(AssetBundle资源包的内部结构)
- Unity5.4 Assetbundles官方说明六(保留下载的AssetBundle)
- Unity5.4 Assetbundles官方说明八(数据安全方面的处理)
- unity3d AssetBundles 资源包
- Unity中AssetBundles一
- 资源包 AssetBundles
- Unity 5.x AssetBundles
- Unity AssetBundles 使用指南
- 【剑指offer】面试题7:用两个栈实现队列
- poj 1797 Heavy Transportation 【dijkstra的变形】
- 解决小米手机不能运行Android Studio程序的问题
- C++之模板priority_queue
- 六大设计原则——依赖倒置原则
- AssetBundles相关的坑
- c语言实现单链表数据结构及其基本操作
- Linux文件同步脚步,SSH免密码远程登录设置Linux
- Oracle 数据主键id自增长
- 配置默认action时报错
- php分页查询
- The one where we all got really cold
- 最大连续数列的和
- MySql数据库优化