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); }
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); }
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); }
private GameObject DoGetFromUnused(string assetPath) { if (!unUsed.ContainsKey(assetPath)) { return(null); } UnusedGo one = unUsed[assetPath]; if (one.IsEmpty) { return(null); } return(one.Peek()); }