/// <summary> /// 从对象池取对象 /// </summary> /// <param name="crc"></param> /// <returns></returns> public ResObject GetObjectFromPool(uint crc) { List <ResObject> st = null; if (mObjectPoolDic.TryGetValue(crc, out st) && st != null && st.Count > 0) { ResObject resObj = st[0]; resObj.Retain(); st.RemoveAt(0); GameObject obj = resObj.mCloneObj; if (!System.Object.ReferenceEquals(obj, null)) { resObj.IsRecyclePool = false; #if UNITY_EDITOR if (obj.name.EndsWith("(Recycle)")) { obj.name = obj.name.Replace("(Recycle)", ""); } #endif } return(resObj); } return(null); }
public void AsyncObjCallBack(bool LoadResult, ResInfo resInfo) { if (!LoadResult) { mAsyncLoadingObjDic.Remove(resInfo.ResPath); ResManager.Instance.RemoveLoadFailRes(resInfo.mCRC); resInfo.Recycle2Cache(); mAsyncLoadingObjDic[resInfo.ResPath].ForEach((objLoadInfo) => { objLoadInfo.loadObjCall.InvokeGracefully(LoadResult, null); objLoadInfo.Recycle2Cache(); }); mAsyncLoadingObjDic.Remove(resInfo.ResPath); return; } bool DestroyCache = false; mAsyncLoadingObjDic[resInfo.ResPath].ForEach((objLoadInfo) => { ResObject resObject = ResObject.Allocate(objLoadInfo); resObject.mObj = resInfo.ResObject; resObject.ABName = resInfo.ABName; resObject.mCloneObj = GameObject.Instantiate(resObject.mObj, objLoadInfo.ObjParentTrans) as GameObject; mObjList.AddValue(resObject.mCloneObj.GetInstanceID()); objLoadInfo.loadObjCall.InvokeGracefully(LoadResult, resObject); ResManager.Instance.CacheResObj(resObject); if (objLoadInfo.mClear) { DestroyCache = true; } resObject.Retain(); resInfo.Retain(); objLoadInfo.Recycle2Cache(); }); resInfo.DestroyCache = DestroyCache; mAsyncLoadingObjDic.Remove(resInfo.ResPath); }