When you make an asset “Addressable,” you can use that asset's address to load it from anywhere. Whether that asset resides in the local application or on a content delivery network, the Addressable system locates and returns it.
Addressable可以从本地或者网络加载资源
When you run the Create Addressables Settings command, the Addressables system creates a folder called, AddressableAssetsData, in which it stores settings files and other assets it uses to keep track of your Addressables setup. You should add the files in this folder to your source control system. Note that Addressables can create additional files as you change your Addressables configuration.
Addressable需要创建单独的资源文件夹存储其设置
Addressables packs assets in a group into AssetBundles according to your group settings when you make a content build.
Addressable底层使用的是AssetBundles,默认每个Group会被打成一个Bundle
AssetReference类型用于引用Addressable资源
资源和文件夹都可以被标记为Addressable
Loading Addressable assets uses asynchronous operations.
Addressable的加载操作是异步的
先勾选Asset的Addressable选项,设定好名字(名字作为访问索引),管理分类窗口在这里:Window > Asset Management > Addressables
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AddressableAssets; // 引入这个 public class WorldManager : MonoBehaviour { void Start() { // 这是一个异步操作,需要指定一个回调函数 // 将一个Asset指定为Addressable,指定好Asset的名字,这里传入的就是Asset的名字(字符串) Addressables.LoadAssetAsync<GameObject>("ChacheData.prefab").Completed += OnLoadDone; } // 注意回调函数的参数列表 void OnLoadDone(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<GameObject> obj) { Debug.Log("Load Asset Done"); } }
主要目的就是,通过代码,自动扫描固定路径下的资源,将其添加到对应的Addressable分组
参考:https://github.com/GZhonghui/UnityTools/blob/master/Wwise/Script/Editor/AD_MarkWwiseAddressable.cs
Build Script / 打包管线:待补充…