/// <summary> /// 同步加载资源,这里不提供进度 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="resType">从哪里加载</param> /// <param name="assetPath"></param> /// <param name="isSprite">是否是加载Sprite</param> /// isRecycleOnDestroy : 当ResLoader被销毁时是否从内存中释放 /// <returns></returns> public T LoadSync <T>(ResFromType resType, string assetPath, bool isSprite = false, bool DestroyCache = false) where T : Object { if (CheckNoCanLoad()) { AFLogger.e("此Loader已经被释放,请注意!"); return(null); } ResLoadInfo resLoadInfo = ResLoadInfo.Allocate(resType, assetPath, isSprite, null, null, DestroyCache); Object resAsset = ResManager.Instance.LoadSync(resLoadInfo); if (resAsset != null) { //加载完成后添加到加载资源列表中 mResList.AddValue(resLoadInfo.mResPath); } resLoadInfo.Recycle2Cache(); return(resAsset as T); }
public void LoadResAsyncForObj(ObjLoadInfo objLoadInfo) { ResInfo resInfo = ResManager.Instance.GetRes(objLoadInfo.mCRC); if (resInfo == null) { ResLoadInfo resLoadInfo = ResLoadInfo.Allocate(objLoadInfo); //资源没有加载 LoadAsync(resLoadInfo); resLoadInfo.Recycle2Cache(); } else if (resInfo.State != ResState.Ready) { //资源正在加载,是其他loader的异步加载 resInfo.RegisterListen(objLoadInfo.loadResCall); } else { //资源已经加载完成,开始回调 objLoadInfo.loadResCall(true, resInfo); } }
public ResObject LoadResSyncForObj(ObjLoadInfo objLoadInfo) { ResObject resObject = ResObject.Allocate(objLoadInfo); ResInfo resInfo = ResManager.Instance.GetRes(objLoadInfo.mCRC); //之前就未加载 if (resInfo == null) { ResLoadInfo resLoadInfo = ResLoadInfo.Allocate(objLoadInfo); resObject.mObj = LoadSync(resLoadInfo); resLoadInfo.Recycle2Cache(); } //之前就加载完成 else if (resInfo.State == ResState.Ready) { resInfo.Retain(); resObject.mObj = resInfo.ResObject; } else { AFLogger.e("同步遇到异步正在或者等待加载的资源 : " + resInfo.ResPath + ",请检查调用代码!"); } return(resObject); }