void Start()
    {
        AssetLabelReference label = new AssetLabelReference();

        label.labelString = "fruit";
        Addressables.LoadResourceLocationsAsync(label.labelString).Completed += OnFruitLoaded;
    }
示例#2
0
        public ResourceComplete(AssetLabelReference assetLabel)
        {
            var tmpHandle = Addressables.LoadAssetsAsync <Object> (assetLabel, null);

            tmpHandle.Completed += OnLoadCompleted;
            handle = tmpHandle;
        }
示例#3
0
        /// <summary>
        /// 异步加载资源集合
        /// </summary>
        /// <param name="label"></param>
        /// <param name="callback"></param>
        /// <param name="completed"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static AsyncOperationHandle <IList <T> > LoadAssetsAsync <T>(AssetLabelReference label, Action <T> callback,
                                                                            Action <AsyncOperationHandle <IList <T> > > completed = null)
        {
            var operation = Addressables.LoadAssetsAsync <T>(label, callback);

            operation.Completed += completed;
            return(operation);
        }
示例#4
0
    public void loadUI()
    {
        //需要将ui用到的物体在addressable中添加“ui”标签,方便统一加载
        AssetLabelReference assetLabelReference = new AssetLabelReference {
            labelString = "ui"
        };

        Addressables.LoadAssetsAsync <GameObject>(assetLabelReference, null).Completed += OnResourceloadFinshed;
    }
示例#5
0
    public static AsyncOperationHandle <IList <T> > LoadAssetsForLabelAsync <T>(AssetLabelReference label, Action <IList <T> > callback)
    {
        var handle = Addressables.LoadAssetsAsync <T>(label, null);

        handle.Completed += (args) =>
        {
            callback?.Invoke(args.Result);
        };
        return(handle);
    }
 void LoadAssetGroup(AssetLabelReference assetLabelReference)
 {
     Addressables.LoadAssetsAsync <GameObject>(assetLabelReference, asset => {
         if (asset == null)
         {
             return;
         }
         Debug.Log($"Adding: {asset}");
     }).Completed += OnComplete;
     _activeAsyncOperations++;
 }
示例#7
0
        public RecycleBin(string _label, AssetLabelReference _prefab, int _preallocateCount = 0,
                          Transform _parent = null, bool _forcePoolParent = true, int _priority = 0)
        {
            label            = _label;
            Prefabs_label    = _prefab;
            PoolParent       = _parent;
            preAllocateCount = _preallocateCount;
            ForcePoolParent  = _forcePoolParent;
            priority         = _priority;

            referenceType = PoolReferenceType.LABEL_REFERENCE;
            Dispose();
        }
示例#8
0
 /// <summary>로드할 리소스 태그를 등록시킵니다.</summary>
 public void Register(AssetLabelReference labelReference)
 {
     labels.Enqueue(labelReference);
 }
    //public static async Task<T> Load<T>(this Object whoIsAskingFor, AssetReference assetReference) where T : Object
    //{
    //	T result = await assetReference.InstantiateAsync().Task as T;
    //	OnAssetReferenceLoaded(result);

    //	return await _assets[result.name].GetAsset<T>(whoIsAskingFor).ConfigureAwait(true);
    //}

    public static async Task PreLoad <T>(this AssetLabelReference labelReference) where T : Object
    {
        var result = await Addressables.LoadAssetsAsync <T>(labelReference.labelString, null).Task;

        OnLabelReferenceLoaded <T>(result);
    }
 public static UniTask <long> GetDownloadSizeAsync(AssetLabelReference assetLabelReference)
 {
     return(GetDownloadSizeAsyncInternal(GetDownloadSizeHandle(assetLabelReference)));
 }
 public static async UniTask <bool> IsContentDownloaded(AssetLabelReference assetLabelReference)
 {
     return(CheckIfContentIsDownloaded(await GetDownloadSizeAsync(assetLabelReference)));
 }
 private static AsyncOperationHandle GetDownloadContentAsyncHandle(AssetLabelReference assetLabelReference)
 {
     return(Addressables.DownloadDependenciesAsync(assetLabelReference, false));
 }
 public static UniTask DownloadContentAsync(Action <DownloadStatus> onDownloadProgressUpdate,
                                            AssetLabelReference assetLabelReference)
 {
     return(DownloadContentAsyncInternal(onDownloadProgressUpdate, GetDownloadContentAsyncHandle(assetLabelReference)));
 }
        /// <summary>
        /// 载入头像资源
        /// </summary>
        /// <param name="lable">载入标志</param>
        /// <returns></returns>
        private async Task <List <Sprite> > LoadSpriteAsync(AssetLabelReference lable)
        {
            var result = await LoaderHelper.LoadAssertsAsync <Sprite>(lable);

            return(result.OrderBy(x => x.name).ToList());
        }
 private AsyncOperationHandle <IList <Object> > LoadAssets(AssetLabelReference assetReference)
 {
     //Debug.Log("LoadAssets: " + assetReference.labelString);
     return(Addressables.LoadAssetsAsync <Object>(assetReference, LoadAssetComplete));
 }
示例#16
0
 /// <summary>
 /// 载入标签资源
 /// </summary>
 /// <typeparam name="T">载入类型</typeparam>
 /// <param name="lable">资源标签</param>
 /// <returns>载入的资源</returns>
 internal static async Task <IList <T> > LoadAssertsAsync <T>(AssetLabelReference lable)
 {
     return(await Addressables.LoadAssetsAsync <T>(lable, null).Task);;
 }