assetbundle是存檔文件,包含可在運(yùn)行時(shí)由Unity加載的特定于平臺(tái)的非代碼資源;AssetBundle可以表示彼此之間的依賴關(guān)系;例如,一個(gè)AssetBundle中的材質(zhì)可以引用另一個(gè)AssetBundle中的紋理,為了提高通過網(wǎng)絡(luò)傳輸?shù)男剩梢愿鶕?jù)用例要求選用內(nèi)置算法選擇來壓縮AssetBundle。
本教程操作環(huán)境:windows10系統(tǒng)、Dell G3電腦。
assetbundle是什么文件?
AssetBundle 是一個(gè)存檔文件,包含可在運(yùn)行時(shí)由 Unity 加載的特定于平臺(tái)的非代碼資源(比如模型、紋理、預(yù)制件、音頻剪輯甚至整個(gè)場景)。AssetBundle 可以表示彼此之間的依賴關(guān)系;例如,一個(gè) AssetBundle 中的材質(zhì)可以引用另一個(gè) AssetBundle 中的紋理。為了提高通過網(wǎng)絡(luò)傳輸?shù)男?,可以根?jù)用例要求(LZMA 和 LZ4)選用內(nèi)置算法選擇來壓縮 AssetBundle。
AssetBundle 可用于可下載內(nèi)容(DLC),減小初始安裝大小,加載針對最終用戶平臺(tái)優(yōu)化的資源,以及減輕運(yùn)行時(shí)內(nèi)存壓力。
Note: An AssetBundle can contain the serialized data of an instance of a code object, such as a ScriptableObject. However, the class definition itself is compiled into one of the Project assemblies. When you load a serialized object in an AssetBundle, Unity finds the matching class definition, creates an instance of it, and sets that instance’s fields using the serialized values. This means that you can introduce new items to your game in an AssetBundle as long as those items do not require any changes to your class definitions.
AssetBundle 中有什么?
“AssetBundle”可以指兩種不同但相關(guān)的東西。
首先是磁盤上的實(shí)際文件。這稱為 AssetBundle 存檔。AssetBundle 存檔是一個(gè)容器,就像文件夾一樣,可以在其中包含其他文件。這些附加的文件包含兩種類型:
-
一個(gè)序列化文件,其中包含分解為各個(gè)對象并寫入此單個(gè)文件的資源。
-
資源文件,這是為某些資源(紋理和音頻)單獨(dú)存儲(chǔ)的二進(jìn)制數(shù)據(jù)塊,允許 Unity 高效地在另一個(gè)線程上從磁盤加載它們。
“AssetBundle”也可以指代通過代碼進(jìn)行交互以便從特定 AssetBundle 存檔加載資源的實(shí)際 AssetBundle 對象。該對象包含您添加到此存檔文件的資源的所有文件路徑的映射。
注意:“AssetBundle Manager”是早期 Unity 版本使用的工具,通過這個(gè)工具可以方便地使用 AssetBundle 來簡化資源管理。從 Unity 2018.2 版開始,應(yīng)改用 Addressable Assets 包,因?yàn)?Unity 已棄用 AssetBundle Manager。