Unity5 assetBundle 更新之-生成所有assetbundle的版本信息
来源:互联网 发布:homebrew mysql 启动 编辑:程序博客网 时间:2024/04/28 11:13
为了确定,哪些assetbundle需要从服务器下载,哪些不需要,在打包完成之后,生成一份txt 文件,保存所有assetbundle的名称和hashcode,只要发现客户端当前版本的hashcode和服务器的不一致,则说明需要下载,当然没有的更需要下载,然后用服务器的txt 文件覆盖客户端的即可。
具体代码如下
其中
Application.dataPath + "/../Assetbundle/Assetbundle" 是总的文件夹的assetbundle,包含了所有assetbbundle的信息,从这个manifest文件中获取所有assetbundle的名称及hashcode。
[MenuItem("BuildAssetbundle/createFileHasCode")] static void createHasTable() { string[] directoryEntries; AssetBundle manifestBundle = AssetBundle.CreateFromFile(Application.dataPath + "/../Assetbundle/Assetbundle"); if (manifestBundle != null) { AssetBundleManifest manifest = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest"); string[] allbundle = manifest.GetAllAssetBundles(); string fileinfo = ""; foreach(string assetname in allbundle) { Hash128 has = manifest.GetAssetBundleHash(assetname); fileinfo += assetname + "," + has.ToString() + "\n"; // Debug.Log(has.GetHashCode().ToString()); } FileStream fs = new FileStream(Application.dataPath + "/../Assetbundle/assetBundleVersion.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(fileinfo); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } }
0 0
- Unity5 assetBundle 更新之-生成所有assetbundle的版本信息
- 【Unity】Unity5版本的AssetBundle打包方案之资源打包
- Unity5的AssetBundle
- Unity5 AssetBundle
- Unity教程之-Unity5.x版本AssetBundle加载研究
- Unity5.x 编辑器中 获取所有标记的 AssetBundle 文件
- 【Unity】Unity5版本的AssetBundle打包方案之打包Scene场景
- 【Unity开发】Unity5.x版本的AssetBundle打包
- 关于Unity5.x版本AssetBundle打包Shader的问题
- Unity5.3.5的AssetBundle加载
- Unity5 AssetBundle的简单使用
- Unity5.x AssetBundle 的变化
- 介绍一下Unity5的AssetBundle
- Unity5.x AssetBundle 的变化
- Unity5的AssetBundle(一、打包)
- [Unity热更新]unity5中的assetbundle
- Unity5.X AssetBundle检测资源更新
- UIFramework之Unity5.x AssetBundle打包策略
- 第四周 单链表的应用(2)——链接
- 第8周 项目1—建立顺序串的算法库
- addEventListener只执行一次即销毁(已兼容)
- 第4周实践项目5--猴子选大王
- 第六周实践项目(1)~建立顺序栈算法库
- Unity5 assetBundle 更新之-生成所有assetbundle的版本信息
- 151012总结
- 第四周 项目二 建立单链表算法库
- 第七周---建立顺序环形队列算法库
- 第四周项目4建设双链表算法库
- UITableView全面解析
- UI线程中调用Handler.post与直接执行方法的区别
- Android Studio在创建/导入项目的时候,一直处于building “XXX”gradle project info的解决办法
- 第6周项目3-括号的匹配