// fields // properties static void AssetBundleRequest_asset(JSVCall vc) { UnityEngine.AssetBundleRequest _this = (UnityEngine.AssetBundleRequest)vc.csObj; var result = _this.asset; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); }
static public int get_allAssets(IntPtr l) { try { UnityEngine.AssetBundleRequest self = (UnityEngine.AssetBundleRequest)checkSelf(l); pushValue(l, self.allAssets); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_asset(IntPtr l) { try { UnityEngine.AssetBundleRequest self = (UnityEngine.AssetBundleRequest)checkSelf(l); pushValue(l, self.asset); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public EStatus LoadAsset(AssetKey key, out AssetAsyncLoad assetLoader) { if (m_CachedAssetBundleObject != null && m_CachedAssetBundleObject.Contains(key.Name)) { SetCachedAssetMap(key, EStatus.Load, null); UnityEngine.AssetBundleRequest asyncRequest = m_CachedAssetBundleObject.LoadAsync(key.Name, key.Type); assetLoader = new AssetAsyncLoad(this, key, asyncRequest); return(EStatus.Load); } assetLoader = default(AssetAsyncLoad); return(EStatus.Error); }
static public int constructor(IntPtr l) { try { UnityEngine.AssetBundleRequest o; o=new UnityEngine.AssetBundleRequest(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
static public int constructor(IntPtr l) { try { UnityEngine.AssetBundleRequest o; o = new UnityEngine.AssetBundleRequest(); pushValue(l, o); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UnityEngine.AssetBundleRequest o; o = new UnityEngine.AssetBundleRequest(); pushValue(l, o); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static void AssetBundleRequest_allAssets(JSVCall vc) { UnityEngine.AssetBundleRequest _this = (UnityEngine.AssetBundleRequest)vc.csObj; var result = _this.allAssets; var arrRet = result; for (int i = 0; arrRet != null && i < arrRet.Length; i++) { JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]); JSApi.moveSaveID2Arr(i); } JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true); }
public static int constructor(IntPtr l) { try { UnityEngine.AssetBundleRequest o; o=new UnityEngine.AssetBundleRequest(); pushValue(l,o); return 1; } catch(Exception e) { LuaDLL.luaL_error(l, e.ToString()); return 0; } }
public virtual bool IsLoaded(Type elementType) { if (ElementWWW.isDone == false) return false; if (request == null) { request = ElementWWW.assetBundle.LoadAsync(this.Name, elementType); } if (request.isDone == false) { return false; } return true; }
static public int LoadAsync(IntPtr l) { try{ UnityEngine.AssetBundle self = (UnityEngine.AssetBundle)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Type a2; checkType(l, 3, out a2); UnityEngine.AssetBundleRequest ret = self.LoadAsync(a1, a2); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
//Begin to load private IEnumerator GoLoader(AssetBundle asset, string resName , FINISH_CALLBACK finish_callback) { this.m_delFinishCallback = finish_callback; this.m_fProgress = 0; this.m_cRequest = asset.LoadAsync(resName, typeof(UnityEngine.Object)); for (; !this.m_cRequest.isDone; ) { this.m_fProgress = this.m_cRequest.progress; yield return new WaitForEndOfFrame(); } this.m_fProgress = 1; if(this.m_delFinishCallback != null) { this.m_delFinishCallback(resName , this.m_cRequest.asset); } GameObject.Destroy(this.gameObject); }
public IEnumerator RunAssetBundleRequestOperation <T>(UnityEngine.AssetBundleRequest asyncOperation, IObserver <T> observer, CancellationToken cancellationToken) where T : UnityEngine.Object { while (!asyncOperation.isDone && !cancellationToken.IsCancellationRequested) { yield return(null); } if (!cancellationToken.IsCancellationRequested) { if (!asyncOperation.asset) { observer.OnError(new System.Exception("RunAssetBundleRequestOperation: Error getting bundle.")); } //Current use case returns the component, if this changes then deal with it downstream but for now this should be ok var go = asyncOperation.asset as GameObject; var comp = go.GetComponent <T>(); observer.OnNext(comp); observer.OnCompleted(); } }
static int LoadAssetWithSubAssetsAsync(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.AssetBundle.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 2) { UnityEngine.AssetBundle obj = (UnityEngine.AssetBundle)ToLua.CheckObject(L, 1, typeof(UnityEngine.AssetBundle)); string arg0 = ToLua.CheckString(L, 2); UnityEngine.AssetBundleRequest o = obj.LoadAssetWithSubAssetsAsync(arg0); ToLua.PushSealed(L, o); return(1); } else if (count == 3) { UnityEngine.AssetBundle obj = (UnityEngine.AssetBundle)ToLua.CheckObject(L, 1, typeof(UnityEngine.AssetBundle)); string arg0 = ToLua.CheckString(L, 2); System.Type arg1 = ToLua.CheckMonoType(L, 3); UnityEngine.AssetBundleRequest o = obj.LoadAssetWithSubAssetsAsync(arg0, arg1); ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AssetBundle.LoadAssetWithSubAssetsAsync")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public override void Unload() { base.Unload(); nav = null; lightmap = null; asset = null; scene = null; requestGo = null; requestNav = null; requestAsset = null; requestTexture = null; { foreach (Material e in mMaterialObject.Values) { Material m = (Material)e; m = null; } mMaterialObject.Clear(); } { foreach (AssetBundleRequest e in mAssetBundleRequestObject.Values) { AssetBundleRequest requestTmp = (AssetBundleRequest)e; requestTmp = null; } mAssetBundleRequestObject.Clear(); } { foreach (ABLoad e in mAbLoadObject) { ABLoad abloadTmp = (ABLoad)e; switch (mABDataType) { case ABDataType.Mpq: ((ABLoadMpq)abloadTmp).Unload(); break; case ABDataType.Normal: ((ABLoadFile)abloadTmp).Unload(); break; } } } if (loadAdapter != null) loadAdapter.Unload(); }
public virtual void Reset(string elementName) { this.request = null; this.Name = elementName; }
internal AssetAsyncLoad(AssetBundleCache origin, AssetKey key, UnityEngine.AssetBundleRequest asyncRequest) { m_Origin = origin; m_Key = key; m_AsyncRequest = asyncRequest; }
public override bool IsDone() { // 如果有依赖,要先判断依赖是否已经加载完成 if (this.dependences != null) { for (int i = 0; i < this.dependences.Length; ++i) { if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i])) return false; } } // 判断自己是否加载完成 if (base.LoadDoneCallback == null) { // 依赖资源,不需要LoadDone回调 if (this.assetbundle != null) return true; if (this.www.isDone) { this.assetbundle = this.www.assetBundle; this.www.Dispose(); this.www = null; return true; } return false; } else { // 直接资源,需要LoadDone回调,所以需要从AssetBundle中提取资源对象 if (this.assetbundleReq != null) { // 只有从assetbundle中提取出最终的资源对象,才算加载完成,保证所有的IO操作都是异步的 return this.assetbundleReq.isDone; } else { if (this.www.isDone) { this.assetbundle = this.www.assetBundle; // 从assetbundle中提取资源对象 string resPath = string.Format(LocalPath.AssetBundleFormation, base.ResName); this.assetbundleReq = this.assetbundle.LoadAssetAsync(resPath); this.www.Dispose(); this.www = null; } return false; } } }
/// <summary> /// 帧频事件 /// </summary> private void enterframe() { if (www != null) { //加载失败 if (!string.IsNullOrEmpty(www.error)) { Debug.LogWarning(LoadConstant.MANIFEST_FILE + "加载失败:" + www.error); LoadFunctionDele _loadFail = m_loadFail; WWW _www = www; clear(); www = null; if (_loadFail != null) { _loadFail(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, _www.progress, _www.error)); } _www.Dispose(); return; } //加载完成 if (www.isDone) { Debug.Log(LoadConstant.MANIFEST_FILE + "加载完成"); //存入本地 if (www.url.Contains(LoadConstant.CDN)) { File.WriteAllBytes(LoadConstant.localFilesPath + "/" + LoadConstant.MANIFEST_FILE, www.bytes); } if (m_loadEnd != null) { m_loadEnd(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, 1)); } request = www.assetBundle.LoadAllAssetsAsync<TextAsset>(); www.Dispose(); www = null; if (m_unZipStart != null) { m_unZipStart(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, 1)); } return; } //加载进度 if (m_loadProgress != null) { m_loadProgress(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, www.progress)); } } else if (request != null) { //解压完成 if (request.isDone) { Debug.Log(LoadConstant.MANIFEST_FILE + "解压完成"); EnterFrame.instance.removeEnterFrame(enterframe); analysis(request.allAssets[0] as TextAsset); m_isInit = true; if(m_unZipEnd != null) { m_unZipEnd(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, 1, null, null, 1, request.allAssets)); } return; } //解压进度 if (m_unZipProgress != null) { m_unZipProgress(LoadData.getLoadData(LoadConstant.MANIFEST_FILE, 1, null, null, request.progress)); } } }