1、Addressable 包和AssetBundle包有啥区别
- Addressable Asset Bundle可以自动加载相关依赖包,而AssetBundle是需要编程实现的;
- Addressable Asset Bundle加载到内存中的bundle有引用计数,而AssetBundle加载到内存中的bundle需要自己进行管理
- Addressable Asset Bundle加载地址灵活;
2、安装Addressables包
打开Unity Editor,通过PackageManager安装Addressable包(如有加密需求,请安装Addressables.CN),Packages选择Unity Registry后搜索Addressables。
![](https://img.haomeiwen.com/i26067915/14b0e59efb8abe5b.png)
![](https://img.haomeiwen.com/i26067915/8bea43921613d839.png)
3、打包流程
3.1 安装完毕后Window > Asset Management > Addressables > Groups
![](https://img.haomeiwen.com/i26067915/768554442fdfe87a.png)
3.2初始化配置
![](https://img.haomeiwen.com/i26067915/f91d1b22fc069353.png)
3.3使用Addressable
-
检查资产检查器中 的可寻址框:
image.png
-
将资产拖到Addressables Groups窗口上的组中:
image.png
-
将资产放入标记为可寻址的项目文件夹中:
image.png
将资产设置为可寻址后,可寻址系统会将其添加到默认组中(除非您将其放置在特定组中)。当您进行内容构建时,Addressables根据您的组设置将组中的资产打包到AssetBundles中。
3.4配置组发布
点击组名,在你的检查器视图内查看打包属性,类似下图。
![](https://img.haomeiwen.com/i26067915/9bf78499f303044f.png)
Build Path 为bundle打包位置
![](https://img.haomeiwen.com/i26067915/0f359edbe474cb8c.png)
Load Path 资源下载路径,一般为了热更会选择远程地址
![](https://img.haomeiwen.com/i26067915/880e8ba01d68f21b.png)
3.5 构建AB包
打开Addressables 界面,点击Build 构建
![](https://img.haomeiwen.com/i26067915/3ca3af63e8ea776e.png)
-
Play Mode Script 选择Use Asset Database(fastest),打包的bundle资源会拷贝到项目的StreamingAssets文件夹下。
image.png
-
Play Mode Script 选择Use Existing Build ,打包的bundle资源不会拷贝到项目StreamingAssets文件夹中,需要远程加载
image.png
3.6更新AB包
a.点击Build后选择Update a Previous Build
![](https://img.haomeiwen.com/i26067915/7de4345f1f31b687.png)
b.选择上次打包的bin文件,在Assets/AddressableAssetsData/{Target}文件夹下
![](https://img.haomeiwen.com/i26067915/6414cdcea62ab687.png)
网友评论