示例#1
0
        private bool GetFromPool(string assetPath, OnGameObjGot cb, bool doneOnUpdate, out ulong taskId)
        {
            taskId = 0;
            if (!unUsed.ContainsKey(assetPath))
            {
                return(false);
            }
            UnusedGo one = unUsed[assetPath];

            if (one.IsEmpty)
            {
                return(false);
            }
            if (doneOnUpdate)
            {
                GoCallback gcb = GenTask(assetPath, cb);
                taskId = gcb.Id;
                onUpdateTasks.Add(taskId);
            }
            else
            {
                GameObject go = one.Peek();
                cb(go, 0);
            }
            return(true);
        }
示例#2
0
        public ulong GetGameObj(string assetPath, OnGameObjGot cb)
        {
            if (unUsed.ContainsKey(assetPath))
            {
                UnusedGo   one = unUsed[assetPath];
                GameObject go  = one.Peek();
                if (null != go)
                {
                    cb(go, 0);
                    return(0);
                }
            }
            if (string.IsNullOrEmpty(assetPath))
            {
                GameObject go = new GameObject();
                cb(go, 0);
                return(0);
            }
            GoCallback gcb = GenTask(assetPath, cb);

            gcb.AssetCbId = BundleMgr.Instance.GetAsset(assetPath, (asset, cbId) =>
            {
                gcb.AssetCbId       = 0;
                IEnumerator instant = Instant(gcb.Id, (UObj)asset);
                instanters.Add(gcb.Id, instant);
                StartCoroutine(instant);
            });
            return(gcb.Id);
        }
示例#3
0
        public void UnuseGameObj(string assetPath, GameObject go)
        {
            if (!unUsed.ContainsKey(assetPath))
            {
                unUsed.Add(assetPath, new UnusedGo(assetPath));
            }
            UnusedGo one = unUsed[assetPath];

            one.Push(go, poolRoot);
        }
示例#4
0
        private GameObject DoGetFromUnused(string assetPath)
        {
            if (!unUsed.ContainsKey(assetPath))
            {
                return(null);
            }
            UnusedGo one = unUsed[assetPath];

            if (one.IsEmpty)
            {
                return(null);
            }
            return(one.Peek());
        }