加载方式
-
await 异步加载
-
回调方式的异步加载。
// 使用Addressable进行异步回调加载 // Addressables.LoadAssetAsync<GameObject>("Sphere").Completed += OnLoadedCompleted; // 使用Addressable进行异步回调实例化 // Addressables.InstantiateAsync("Sphere").Completed += OnLoadedCompleted;
打包方式
- 没有额外设置,每个标记了Addressable的都会打成一个单独的bundle。
- 将要打成一个ab的资源,设置为一个Group并且设置pack mode 为together
引用计数
在Monobehaviour中使用AssetReference关联资源
- 所有使用的资源都是一个AssetReference。需要手动使用AssetReference进行加载和卸载。
- 只能计算Addressable系统自己管理的部分(使用Addressable.Instantiate而不是Object.Instantiate)
- 目前看来需要手动调用AssetReference.ReleaseAsset和ReleaseInstance。
在脚本中使用Addressables的静态接口
- 使用Addressables的接口加载和实例化资源,并且需要调用接口卸载资源。
- 其他方式实例化的资源不会计算进入引用计数
Analyze
对工程中的Addressable的资源根据已有Rule以及自定义Rule进行分析。
- Check Duplicate Bundle Dependencies:检查是否有重复引用的资源。两个Addressable资源引用了同一个非Addressable资源
- Build Bundle Layout:查看当前的Assetbundle的布局,就是工程中有哪些Ab,Ab中包含了哪些资源。