总结一下Assetbundle的一些实战技巧

2021/9/29 23:12:38

本文主要是介绍总结一下Assetbundle的一些实战技巧,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

国庆赋闲在家,所以有时间搞搞Unity的Assetbundle资源加载

重点如下:

1.下面的几点zaiji某些同仁总结的好,而且我自己实践过一遍确实如此

2.很多基础方法,基础API,无论Unity怎么升级也没有变,且不说要不要向前兼容,官方自身也不敢改动太多(一个没什么错的代码,你会随便去改么?)

Unity的资源加载分类:

  • Resource
  • DataPath
  • PesistantPath
  • StreamingAssets
  • AssetDataBase

StreamingAssets 资源处理

StreamingAssets下面的文件读取有一些规则还是得注意一下,有点记忆偏差就会出事。

1. StreamingAssets目录直接用Application.streamingAssetsPath获取就行;

2. AssetBundle.LoadFromFile可以读取StreamingAssets下的AssetBundle;

3. Windows & ios平台,用C# File类是可以读取普通文件的;

4. Android平台,用C# File类不可以读取普通文件,这个一定要注意,原因看官方文档

    https://docs.unity3d.com/Manual/StreamingAssets.html

    On Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file. 

    Android平台可以用WWW读取。

AssetBundle内存占用

优化和原理可参考之前的博客:

AssetBundle包解析,反编译 


AssetBundle资源包统计和分析

‘同样可参考之前博客:

 



这篇关于总结一下Assetbundle的一些实战技巧的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程