总结一下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的一些实战技巧的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28微服务架构中API版本控制的实践
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南