/// <summary> /// 加载资源 /// </summary> /// <param name="resName"></param> /// <param name="loadDone"></param> /// <param name="updateProgress"></param> public void LoadRes(string resName, ResourceLoader.LoadResDoneCallback loadDone = null) { IResLoader loader = null; #if ASSETBUNDLE AssetBundleLoader abLoader = null; // 如果已经加载过这个AssetBundle if (this.loadedAssetBundleLoaderDict.TryGetValue(resName, out abLoader)) { // 检查依赖及assetbundle解压 abLoader.CheckDependences(); this.loadedAssetBundleLoaderDict.Remove(resName); this.loadingResDict[resName] = abLoader; return; } #endif // 如果正在加载中,则将加载回调添加到已有的加载器 if (this.loadingResDict.TryGetValue(resName, out loader)) { //Debug.LogWarning(resName + " loading"); if (loadDone != null) { loader.LoadDoneCallback += loadDone; } return; } // 新建加载器开始加载 #if ASSETBUNDLE loader = new AssetBundleLoader(resName, loadDone); #else loader = new ResourceLoader(resName, loadDone); #endif // 添加至正在加载列表 AddLoadingLoader(loader); // 启动加载 Game.Instance().StartCoroutine(loader); }
static internal int checkDelegate(IntPtr l, int p, out ResourceLoader.LoadResDoneCallback ua) { int op = extractFunction(l, p); if (LuaDLL.lua_isnil(l, p)) { ua = null; return(op); } else if (LuaDLL.lua_isuserdata(l, p) == 1) { ua = (ResourceLoader.LoadResDoneCallback)checkObj(l, p); return(op); } LuaDelegate ld; checkType(l, -1, out ld); if (ld.d != null) { ua = (ResourceLoader.LoadResDoneCallback)ld.d; return(op); } LuaDLL.lua_pop(l, 1); l = LuaState.get(l).L; ua = (string a1, UnityEngine.Object a2) => { int error = pushTry(l); pushValue(l, a1); pushValue(l, a2); ld.pcall(2, error); LuaDLL.lua_settop(l, error - 1); }; ld.d = ua; return(op); }