示例#1
0
 private void StartLoadAsync(string resourcesPath, ObjectCallback callBack, IsObjectOldFunc oldFunc)
 {
     _curLoadingCount++;
     CoroutineHelper.StartCoroutine(LoadAssetCoroutine(resourcesPath, (asset, isOld) => {
         AssetUtil.OnCallBack(callBack, asset, isOld);
         OnLoadFinishAndCheckNext();
     }, oldFunc));
 }
示例#2
0
        private IEnumerator LoadAssetCoroutine(string path, ObjectCallback callBack, IsObjectOldFunc func)
        {
            ResourceRequest request   = Resources.LoadAsync(path);
            float           startTime = Time.time;

            while (request.isDone == false)
            {
                if ((Time.time - startTime) >= MAX_LAOD_TIME)
                {
                    Debug.LogError("LoadAsset time out" + path);
                    break;
                }

                yield return(null);
            }

            UnityEngine.Object prefab = request.asset;
            AssetUtil.OnCallBack(callBack, prefab, func);
        }
示例#3
0
        public void LoadAssetAsync(int assetId, ObjectCallback callBack, IsObjectOldFunc func)
        {
            AssetInfo info = _assetInfoManager.GetAssetInfo(assetId);

            if (info == null)
            {
                AssetUtil.OnCallBack(callBack, null, false);
                return;
            }

            if (_curLoadingCount < MAX_ASYNC_LOADING_COUNT)
            {
                StartLoadAsync(info.ResourcesPath, callBack, func);
            }
            else
            {
                AssetLoaderTask task = new AssetLoaderTask(info, callBack, func);
                //添加异步加载任务
                pengdingLoadQueue.Enqueue(task);
            }
        }
示例#4
0
        public void LoadAssetAsync(int assetId, ObjectCallback callBack, IsObjectOldFunc func)
        {
            var obj = GetFromCache(assetId);

            if (obj != null)
            {
                AssetUtil.OnCallBack(callBack, obj, func);
                return;
            }

            ObjectCallback proxyCallback = (asset, isOld) => {
                if (asset != null)
                {
                    if (!_cacheAssets.ContainsKey(assetId))
                    {
                        PushToCache(assetId, asset);
                    }
                }

                AssetUtil.OnCallBack(callBack, asset, isOld);
            };

            _loaderReal.LoadAssetAsync(assetId, proxyCallback, func);
        }
        public void LoadAssetAsync(int assetId, ObjectCallback callBack, IsObjectOldFunc func)
        {
            var obj = LoadAsset <UnityEngine.Object>(assetId);

            AssetUtil.OnCallBack(callBack, obj, func);
        }