赞
踩
之前大家使用热更的时候都使用的是unity3d自带的assetbundle(AB)包,但是说实话对于使用来说还是存在着非常大的问题的
资源设置为addressable
设置资源对应的路径
设置生成和加载的路径
设置运行模式
把我们标记为address的生成出来.
加载这个资源
using UnityEngine; using UnityEngine.AddressableAssets; public class samplesuse : MonoBehaviour { // Start is called before the first frame update void Start() { LoadAE(); } public void LoadAE() { Addressables.LoadAssetAsync<GameObject>("Assets/Cube.prefab").Completed += LoadCubeCompleted; } private void LoadCubeCompleted(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<GameObject> obj) { Addressables.InstantiateAsync("Assets/Cube.prefab"); Instantiate(obj.Result); } }
加载引用资源
build不允许使用引入资源
引入资源
预制体孵化器,可以直接孵化addressable的预制体,并且可以调整生成时间,存活时间,等参数.
using UnityEngine; using UnityEngine.AddressableAssets; public class loadotherae : MonoBehaviour { // Start is called before the first frame update void Start() { string url = @"E:\WorkStations\Unity\addressenble\Library\com.unity.addressables\aa\Windows\catalog.json"; Addressables.LoadContentCatalogAsync(url).Completed += (arg) => { Addressables.LoadAssetAsync<GameObject>("Assets/Cube.prefab").Completed += LoadCubeCompleted; }; } private void LoadCubeCompleted(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<GameObject> obj) { Addressables.InstantiateAsync("Assets/Cube.prefab"); Instantiate(obj.Result); } }
https://docs.unity.cn/Packages/com.unity.addressables@1.18/manual/MultiProject.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。