AssetBundles
本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2019.2版本
参考链接:https://docs.unity3d.com/Manual/AssetBundlesIntro.html
An AssetBundle is an archive file that contains platform-specific non-code Assets (such as Models, Textures, Prefabs, Audio clips, and even entire Scenes) that Unity can load at run time. AssetBundles can express dependencies between each other; for example, a Material in one AssetBundle can reference a Texture in another AssetBundle. For efficient delivery over networks, you can compress AssetBundles with a choice of built-in algorithms depending on use case requirements (LZMA and LZ4).
AssetBundle(资产包)是一个压缩存储文件的方式,它包含Unity可以在运行时加载的特定于平台的非代码资产(例如模型、纹理、预置、音频剪辑,甚至整个场景)。资产包可以表示彼此之间的依赖关系;例如,一个资产包中的材质可以引用另一个资产包中的纹理。为了在网络上高效地传递,您可以根据本地需求(LZMA和LZ4)选择内置算法来压缩资产包。
AssetBundles can be useful for downloadable content (DLC), reducing initial install size, loading assets optimized for the end-user’s platform, and reduce runtime memory pressure.
Assetbundle(资产包)对于可下载内容(DLC)、减少初始安装大小、加载针对最终用户平台优化的资产以及减少运行时内存压力非常有用。
What’s in an AssetBundle?
“AssetBundle” can refer to two different, but related things.
“AssetBundle”可以指两个不同但相关的东西。
First is the actual file on disk. This is called the AssetBundle archive. The AssetBundle archive is a container, like a folder, that holds additional files inside it. These additional files consist of two types:
首先是磁盘上的实际文件。这称为AssetBundle存储。AssetBundle存储是一个容器,类似于一个文件夹,其中包含附加文件。这些附加文件包括两种类型:
- A serialized file, which contains your Assets broken out into their individual objects and written out to this single file.
一个序列化文件,其中包含您的资产分解为各自的对象并写入到这个文件中。 - Resource files, which are chunks of binary data stored separately for certain Assets (Textures and audio) to allow Unity to efficiently load them from disk on another thread.
资源文件,它是为某些资产(纹理和音频)单独存储的二进制数据块,允许Unity有效地在另一个线程从磁盘上加载它们。
“AssetBundle” can also refer to the actual AssetBundle object you interact with via code to load Assets from a specific AssetBundle archive. This object contains a map of all the file paths of the Assets you added to this archive.
“AssetBundle”还可以指您通过代码与之交互的实际AssetBundle对象,以从特定的AssetBundle存储包中加载资产。此对象包含您添加到此包体中资产的所有文件路径的映射。
For more information, see the tutorial on Assets, Resources and AssetBundles.