示例#1
0
 protected override void OnDone()
 {
     base.OnDone();
     Broadcast(null, AssetBundleEventNameConst.On_AssetBundleAsyncLoader_Done, this);
     this.Destroy();
     PoolCatManagerUtil.Despawn(this);
 }
示例#2
0
        public AbstractEntity[] GetChildrenStrictly(Type childType)
        {
            List <AbstractEntity> list = new List <AbstractEntity>();

            try
            {
                if (!this.typeToChildListDict.ContainsKey(childType))
                {
                    return(list.ToArray());
                }
                var childList = typeToChildListDict[childType];
                for (var i = 0; i < childList.Count; i++)
                {
                    var child = childList[i];
                    if (!child.IsDestroyed())
                    {
                        list.Add(child);
                    }
                }

                return(list.ToArray());
            }
            finally
            {
                list.Clear();
                PoolCatManagerUtil.Despawn(list);
            }
        }
示例#3
0
        public IEnumerator Initialize()
        {
            if (Application.isEditor && EditorModeConst.IsEditorMode)
            {
                yield break;
            }

            manifest       = new Manifest();
            assetPathMap   = new AssetPathMap();
            assetBundleMap = new AssetBundleMap();

            // 说明:同时请求资源可以提高加载速度
            var manifestRequest =
                DownloadFileAsyncNoCache(
                    manifest.assetBundleName.WithRootPath(FilePathConst.PersistentAssetBundleRoot));
            var assetPathMapRequest =
                DownloadFileAsyncNoCache(
                    BuildConst.AssetPathMap_File_Name.WithRootPath(FilePathConst.PersistentAssetBundleRoot));
            var assetBundleMapRequest =
                DownloadFileAsyncNoCache(
                    BuildConst.AssetBundleMap_File_Name.WithRootPath(FilePathConst.PersistentAssetBundleRoot));

            yield return(manifestRequest);

            if (manifestRequest.error.IsNullOrWhiteSpace())
            {
                var assetBundle = manifestRequest.assetBundle;
                manifest.LoadFromAssetBundle(assetBundle);
                assetBundle.Unload(false);
                manifestRequest.Destroy();
                PoolCatManagerUtil.Despawn(manifestRequest);
            }


            yield return(assetPathMapRequest);

            if (assetPathMapRequest.error.IsNullOrWhiteSpace())
            {
                assetPathMap.Initialize(assetPathMapRequest.text);
                assetPathMapRequest.Destroy();
                PoolCatManagerUtil.Despawn(assetPathMapRequest);
            }

            yield return(assetBundleMapRequest);

            if (assetBundleMapRequest.error.IsNullOrWhiteSpace())
            {
                assetBundleMap.Initialize(assetBundleMapRequest.text);
                assetBundleMapRequest.Destroy();
                PoolCatManagerUtil.Despawn(assetBundleMapRequest);
            }

            LogCat.Log("AssetMananger init finished");
        }
示例#4
0
 public void Reset()
 {
     onSuccessCallback = null;
     onFailCallback    = null;
     onDoneCallback    = null;
     if (_resultInfo != null)
     {
         PoolCatManagerUtil.Despawn(_resultInfo);
     }
     _resultInfo = null;
 }
示例#5
0
        void _OnDespawn_Component()
        {
            keyToComponentDict.Clear();
            foreach (var componentList in typeToComponentListDict.Values)
            {
                componentList.Clear();
                PoolCatManagerUtil.Despawn(componentList);
            }

            typeToComponentListDict.Clear();
            componentKeyList.Clear();
            componentTypeList.Clear();
        }
示例#6
0
        public IEnumerator LoadAssetPathMap()
        {
            var assetPathMapRequestUrl = BuildConst.AssetPathMap_File_Name.WithRootPath(urlRoot);
            var assetPathMapRequest    = Client.instance.assetBundleManager.DownloadFileAsyncNoCache(assetPathMapRequestUrl);

            yield return(assetPathMapRequest);

            if (assetPathMapRequest.error.IsNullOrWhiteSpace())
            {
                assetPathMap.Initialize(assetPathMapRequest.text);
            }
            assetPathMapRequest.Destroy();
            PoolCatManagerUtil.Despawn(assetPathMapRequest);
        }
示例#7
0
        public IEnumerator LoadResVersion()
        {
            var resVersionRequestUrl = BuildConst.ResVersionFileName.WithRootPath(urlRoot);
            var resVersionRequest    = Client.instance.assetBundleManager.DownloadFileAsyncNoCache(resVersionRequestUrl);

            yield return(resVersionRequest);

            if (resVersionRequest.error.IsNullOrWhiteSpace())
            {
                resVersion = resVersionRequest.text;
            }
            resVersionRequest.Destroy();
            PoolCatManagerUtil.Despawn(resVersionRequest);
        }
示例#8
0
        private void OnAssetAsyncLoaderDone(AssetAsyncLoader assetAsyncLoader)
        {
            if (!assetAsyncloaderProcessingList.Contains(assetAsyncLoader))
            {
                return;
            }

            //解除对assetAsyncLoader的引用
            assetAsyncLoader.assetCat.SubRefCount();

            assetAsyncloaderProcessingList.Remove(assetAsyncLoader);
            assetAsyncLoader.Destroy();
            PoolCatManagerUtil.Despawn(assetAsyncLoader);
        }
示例#9
0
        public IEnumerator LoadAssetPathRefContentJson()
        {
            var assetPathRefContentJsonRequestURL        = AssetPathRefConst.SaveFileName.WithRootPath(urlRoot);
            var assetPathRefContentJsonRequestURLRequest =
                Client.instance.assetBundleManager.DownloadFileAsyncNoCache(assetPathRefContentJsonRequestURL);

            yield return(assetPathRefContentJsonRequestURLRequest);

            if (assetPathRefContentJsonRequestURLRequest.error.IsNullOrWhiteSpace())
            {
                assetPathRefContentJson = assetPathRefContentJsonRequestURLRequest.text;
            }
            assetPathRefContentJsonRequestURLRequest.Destroy();
            PoolCatManagerUtil.Despawn(assetPathRefContentJsonRequestURLRequest);
        }
        public void RemoveAllChildren()
        {
            var toRemoveChildKeyList = PoolCatManagerUtil.Spawn <List <string> >();

            toRemoveChildKeyList.Capacity = this.childKeyList.Count;
            toRemoveChildKeyList.AddRange(this.childKeyList);
            for (var i = 0; i < toRemoveChildKeyList.Count; i++)
            {
                var childKey = toRemoveChildKeyList[i];
                RemoveChild(childKey);
            }

            toRemoveChildKeyList.Clear();
            PoolCatManagerUtil.Despawn(toRemoveChildKeyList);
        }
示例#11
0
        void _OnDespawn_Child()
        {
            keyToChildDict.Clear();
            foreach (var childList in typeToChildListDict.Values)
            {
                childList.Clear();
                PoolCatManagerUtil.Despawn(childList);
            }

            typeToChildListDict.Clear();
            childKeyList.Clear();
            childTypeList.Clear();
            _parent = null;
            isKeyUsingParentIdPool = false;
        }
        public void RemoveAllComponents()
        {
            var toRemoveComponentKeyList = PoolCatManagerUtil.Spawn <List <string> >();

            toRemoveComponentKeyList.Capacity = this.componentKeyList.Count;
            toRemoveComponentKeyList.AddRange(componentKeyList);
            for (var i = 0; i < toRemoveComponentKeyList.Count; i++)
            {
                var componentKey = toRemoveComponentKeyList[i];
                RemoveComponent(componentKey);
            }

            toRemoveComponentKeyList.Clear();
            PoolCatManagerUtil.Despawn(toRemoveComponentKeyList);
        }
示例#13
0
        /// <summary>
        /// 添加到对应的TimerList中
        /// </summary>
        /// <param name="timer"></param>
        public void RemoveTimer(Timer timer, int?index = null)
        {
            List <Timer> timerList = this.GetTimerList(timer.updateMode);

            if (index != null)
            {
                timerList.RemoveAt(index.Value);
            }
            else
            {
                timerList.Remove(timer);
            }

            timer.Finish();
            PoolCatManagerUtil.Despawn(timer);
        }
示例#14
0
        public IEnumerator LoadManifest()
        {
            var manifestRequestURL = BuildConst.ManifestBundle_Path.WithRootPath(urlRoot);

            manifestRequest = Client.instance.assetBundleManager.DownloadFileAsyncNoCache(manifestRequestURL);
            yield return(manifestRequest);

            if (manifestRequest.error.IsNullOrWhiteSpace())
            {
                manifest.LoadFromAssetBundle(manifestRequest.assetBundle);
                manifest.SaveBytes(manifestRequest.bytes);
                manifestRequest.assetBundle.Unload(false);
            }

            manifestRequest.Destroy();
            PoolCatManagerUtil.Despawn(manifestRequest);
        }
示例#15
0
        public AbstractEntity[] GetChildren(Type childType)
        {
            List <AbstractEntity> list = PoolCatManagerUtil.Spawn <List <AbstractEntity> >();

            try
            {
                foreach (var child in ForeachChild(childType))
                {
                    list.Add(child);
                }
                return(list.ToArray());
            }
            finally
            {
                list.Clear();
                PoolCatManagerUtil.Despawn(list);
            }
        }
示例#16
0
 private void OnResourceWebRequesterDone(ResourceWebRequester resourceWebRequester)
 {
     if (!resourceWebRequesterProcessingList.Contains(resourceWebRequester))
     {
         return;
     }
     resourceWebRequesterProcessingList.Remove(resourceWebRequester);
     resourceWebRequesterAllDict.RemoveByFunc((k, v) => v == resourceWebRequester);
     // 无缓存,不计引用计数、Creater使用后由上层回收,所以这里不需要做任何处理
     if (!resourceWebRequester.isNotCache)
     {
         var assetBundleCat = resourceWebRequester.assetBundleCat;
         // 解除webRequester对AB持有的引用
         assetBundleCat?.SubRefCount();
         resourceWebRequester.Destroy();
         PoolCatManagerUtil.Despawn(resourceWebRequester);
     }
 }
示例#17
0
        //max_reload_count 失败的重新load的最大次数
        public IEnumerator DownloadFileAsync(string downloadURL, string filePath, int maxReloadCount, int curReloadCount = 0)
        {
            var resourceWebRequester = DownloadFileAsyncNoCache(downloadURL, filePath);

            curReloadCount++;
            yield return(resourceWebRequester);

            while (curReloadCount < maxReloadCount)
            {
                if (!resourceWebRequester.error.IsNullOrWhiteSpace())
                {
                    LogCat.LogError(resourceWebRequester.error);
                    resourceWebRequester.Destroy();
                    PoolCatManagerUtil.Despawn(resourceWebRequester);
                    resourceWebRequester = DownloadFileAsyncNoCache(downloadURL, filePath);
                    yield return(resourceWebRequester);
                }
                curReloadCount++;
            }
        }
示例#18
0
        private void OnResourceWebRequesterDone(ResourceWebRequester resourceWebRequester)
        {
            //    LogCat.LogError("kkkkkkkkkkkkkkk:"+resourceWebRequester.url);
            if (!downloadingRequestList.Contains(resourceWebRequester))
            {
                return;
            }

            if (!resourceWebRequester.error.IsNullOrWhiteSpace())
            {
                LogCat.LogError("Error when downloading file : " + resourceWebRequester.cache.Get <string>("file_path") +
                                "\n from url : " +
                                resourceWebRequester.url + "\n err : " + resourceWebRequester.error);
                needDownloadList.Add(resourceWebRequester.cache.Get <string>("file_path"));
            }
            else
            {
                downloadingRequestList.Remove(resourceWebRequester);
                needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["is_finished"]     = true;
                needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["downloded_bytes"] =
                    needDownloadDict[resourceWebRequester.cache.Get <string>("file_path")]["total_bytes"];
                var filePath = resourceWebRequester.cache.Get <string>("file_path")
                               .WithRootPath(FilePathConst.PersistentAssetBundleRoot);
                StdioUtil.WriteFile(filePath, resourceWebRequester.bytes);
            }

            resourceWebRequester.Destroy();
            PoolCatManagerUtil.Despawn(resourceWebRequester);

            //    LogCat.LogError("ffffffffffffaaaaaaa:"+downloadingRequest.Count);
            //    LogCat.LogError("ffffffffffffbbbbbbb:" + needDownloadList.Count);
            if (downloadingRequestList.Count == 0 && needDownloadList.Count == 0)
            {
                isUpdatingRes = false;
            }
        }
示例#19
0
 public static void Despawn(this object self)
 {
     PoolCatManagerUtil.Despawn(self);
 }
示例#20
0
 public virtual void Dispose()
 {
     PoolCatManagerUtil.Despawn(this);
 }
示例#21
0
 public override void Dispose()
 {
     PoolCatManagerUtil.Despawn(_spawn);
     _spawn = default;
     base.Dispose();
 }