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); }
private GoCallback GenTask(string resPath, OnGameObjGot cb) { GoCallback gcb = GoCallback.Gen(cb, resPath); goTasks.Add(gcb.Id, gcb); return(gcb); }
public ulong GetGameObj(string assetPath, OnGameObjGot cb, bool doneOnUpdate = false) { if (string.IsNullOrEmpty(assetPath)) { cb(null, 0); return(0); } ulong taskId = 0; if (GetFromPool(assetPath, cb, doneOnUpdate, out taskId)) { return(taskId); } #if UNITY_EDITOR if (!AppEnv.UseBundleInEditor) { var obj = AssetDatabase.LoadAssetAtPath <GameObject>(assetPath); GameObject tempGo = null == obj?null: Instantiate(obj); //if(null!=tempGo) // ApplyShader.CheckShader(tempGo); cb(tempGo, 0); return(0); } #endif return(GetByLoad(assetPath, cb, doneOnUpdate)); }
public static GoCallback Gen(OnGameObjGot cb, string path) { GoCallback acb = new GoCallback(cb, path); items.Add(acb.Id, acb); return(acb); }
private GoCallback(OnGameObjGot cb, string path) { id = ++idLast; this.cb = cb; this.path = path; Canceled = false; }
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); }
private ulong GetByLoad(string assetPath, OnGameObjGot cb, bool doneOnUpdate) { GoCallback gcb = GenTask(assetPath, cb); gcb.AssetCbId = BundleMgr.Instance.GetAsset(assetPath, (asset, cbId) => { gcb.AssetCbId = 0; if (doneOnUpdate) { gcb.Asset = (UObj)asset; onUpdateTasks.Add(gcb.Id); } else { IEnumerator instant = Instant(gcb.Id, (UObj)asset); instanters.Add(gcb.Id, instant); StartCoroutine(instant); } }); return(gcb.Id); }