static int _m_LoadLocalBundleAsync(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Casinos.LuaMgr gen_to_be_invoked = (Casinos.LuaMgr)translator.FastGetCSObj(L, 1); { XLua.LuaTable _lua_table = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable)); XLua.LuaTable _need_load_ab_path = (XLua.LuaTable)translator.GetObject(L, 3, typeof(XLua.LuaTable)); Casinos.DelegateLua4 _loaded_callback = translator.GetDelegate <Casinos.DelegateLua4>(L, 4); LoaderTicket gen_ret = gen_to_be_invoked.LoadLocalBundleAsync(_lua_table, _need_load_ab_path, _loaded_callback); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
//--------------------------------------------------------------------- void _wwwCallBack(UnityEngine.Object obj, LoaderTicket tick) { if (this.displayObject.gameObject == null) { return; } if (LoaderTicket != tick) { return; } LoaderTicket = null; bool load_success = false; Texture2D t = (Texture2D)obj; if (t != null) { var p = t.GetPixels(); var p1 = new Texture2D(t.width, t.height, TextureFormat.ARGB32, false); p1.SetPixels(p); p1.Apply(); load_success = true; onExternalLoadSuccess(new NTexture(p1)); } else { onExternalLoadFailed(); } if (LoaderDoneCallBack != null) { LoaderDoneCallBack(load_success); } }
//--------------------------------------------------------------------- public LoaderTicket getTexture(string name, string path, Action <LoaderTicket, Texture> call_back) { Texture texture = null; MapTexture.TryGetValue(name, out texture); LoaderTicket tick = null; if (texture == null) { tick = CasinosContext.Instance.AsyncAssetLoadGroup.asyncLoadAsset( path, name, _eAsyncAssetLoadType.LocalBundleAsset, (LoaderTicket ticket, string path_ex, UnityEngine.Object obj) => { texture = (Texture)obj; MapTexture[name] = texture; call_back(ticket, texture); }); } else { call_back(tick, texture); } return(tick); }
//------------------------------------------------------------------------- public LoaderTicket getAssetBundle(string bundle_path, Action <string, AssetBundle> asset_bundle_callback) { LoaderTicket loader_ticket = new LoaderTicket(); AssetBundleCreateRequest assetbundle_createrequest = null; if (!MapAssetBundleCreateRequest.TryGetValue(bundle_path, out assetbundle_createrequest)) { assetbundle_createrequest = AssetBundle.LoadFromFileAsync(bundle_path); MapAssetBundleCreateRequest[bundle_path] = assetbundle_createrequest; } Action <string, AssetBundle> ticketandcallback = null; if (!MapLoaderTicketAndCallBack.TryGetValue(bundle_path, out ticketandcallback)) { ticketandcallback = asset_bundle_callback; MapLoaderTicketAndCallBack[bundle_path] = ticketandcallback; } else { ticketandcallback += asset_bundle_callback; } return(loader_ticket); }
public void __Gen_Delegate_Imp30(LoaderTicket p0, string p1, UnityEngine.Object p2) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int err_func = LuaAPI.load_error_func(L, errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); translator.Push(L, p0); LuaAPI.lua_pushstring(L, p1); translator.Push(L, p2); int __gen_error = LuaAPI.lua_pcall(L, 3, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
static int _m_asyncLoadAsset(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); AsyncAssetLoadGroup gen_to_be_invoked = (AsyncAssetLoadGroup)translator.FastGetCSObj(L, 1); { string _bundle_path = LuaAPI.lua_tostring(L, 2); string _asset_name = LuaAPI.lua_tostring(L, 3); _eAsyncAssetLoadType _loader_type; translator.Get(L, 4, out _loader_type); System.Action <LoaderTicket, string, UnityEngine.Object> _loaded_action = translator.GetDelegate <System.Action <LoaderTicket, string, UnityEngine.Object> >(L, 5); LoaderTicket gen_ret = gen_to_be_invoked.asyncLoadAsset(_bundle_path, _asset_name, _loader_type, _loaded_action); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_asyncLoadLocalBundle(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); AsyncAssetLoadGroup gen_to_be_invoked = (AsyncAssetLoadGroup)translator.FastGetCSObj(L, 1); { System.Collections.Generic.List <string> _list_bundle_path = (System.Collections.Generic.List <string>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <string>)); _eAsyncAssetLoadType _loader_type; translator.Get(L, 3, out _loader_type); System.Action <System.Collections.Generic.List <UnityEngine.AssetBundle> > _loaded_action = translator.GetDelegate <System.Action <System.Collections.Generic.List <UnityEngine.AssetBundle> > >(L, 4); LoaderTicket gen_ret = gen_to_be_invoked.asyncLoadLocalBundle(_list_bundle_path, _loader_type, _loaded_action); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_LoadWWWAsync(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); AsyncAssetLoadGroup gen_to_be_invoked = (AsyncAssetLoadGroup)translator.FastGetCSObj(L, 1); { string _url = LuaAPI.lua_tostring(L, 2); System.Action <string, UnityEngine.WWW> _loaded_action = translator.GetDelegate <System.Action <string, UnityEngine.WWW> >(L, 3); LoaderTicket gen_ret = gen_to_be_invoked.LoadWWWAsync(_url, _loaded_action); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
//--------------------------------------------------------------------- protected override void LoadExternal() { Texture2D tex = null; string url = this.url.Replace('\\', '/'); int index = url.LastIndexOf('/'); string resource_name = url.Substring(index + 1); if (this.url.StartsWith(HttpPrefix) || this.url.StartsWith(HttpsPrefix)) { var loader_ticket = HeadIconMgr.Instant.asyncLoadIcon(resource_name, this.url, resource_name, null, _wwwCallBack); if (loader_ticket != null) { LoaderTicket = loader_ticket; } } else { if (this.url.EndsWith(ABPostfix)) { var loader_ticket = TextureMgr.Instant.getTexture(resource_name.Replace(ABPostfix, ""), this.url, _loadTextureCallBackEx); if (loader_ticket != null) { LoaderTicket = loader_ticket; } } else { tex = Resources.Load <Texture2D>(this.url); _loadTextureCallBack(tex); } } }
//--------------------------------------------------------------------- void _loadTextureCallBackEx(LoaderTicket tick, Texture t) { if (LoaderTicket != tick) { return; } LoaderTicket = null; _loadTextureCallBack(t); }
//--------------------------------------------------------------------- public LoaderTicket asyncLoadIcon(string id, string resource_path, string resource_name, GameObject head_icon, Action <UnityEngine.Object, LoaderTicket> load_callback = null) { LoaderTicket loader_ticket = null; Texture head_resource = null; if (MapHeadIconResources.TryGetValue(id, out head_resource)) { if (head_icon != null) { head_icon.SetActive(true); //UiHelper.setActiveState(true, head_icon); //UiHelper.setTexture(head_icon, head_resource); } if (load_callback != null) { load_callback(head_resource, loader_ticket); } } else { if (MapLoadingIcon.ContainsKey(id)) { return(loader_ticket); } MapLoadingIcon[id] = id; loader_ticket = CasinosContext.Instance.AsyncAssetLoadGroup.asyncLoadAsset( resource_path, resource_name, _eAsyncAssetLoadType.WWWRawAsset, (LoaderTicket ticket, string path, UnityEngine.Object obj) => { MapLoadingIcon.Remove(id); if (obj != null) { MapHeadIconResources[id] = (Texture)obj; if (head_icon != null) { head_icon.SetActive(true); //UiHelper.setActiveState(true, head_icon); //UiHelper.setTexture(head_icon, (Texture)obj); } } if (load_callback != null) { load_callback(obj, loader_ticket); } }); } return(loader_ticket); }
static int _s_set_MapLoadedAssetBundle(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LoaderTicket gen_to_be_invoked = (LoaderTicket)translator.FastGetCSObj(L, 1); gen_to_be_invoked.MapLoadedAssetBundle = (System.Collections.Generic.Dictionary <string, UnityEngine.AssetBundle>)translator.GetObject(L, 2, typeof(System.Collections.Generic.Dictionary <string, UnityEngine.AssetBundle>)); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(0); }
static int _g_get_MapLoadedAssetBundle(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LoaderTicket gen_to_be_invoked = (LoaderTicket)translator.FastGetCSObj(L, 1); translator.Push(L, gen_to_be_invoked.MapLoadedAssetBundle); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(1); }
static int _g_get_UserData(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); LoaderTicket gen_to_be_invoked = (LoaderTicket)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, gen_to_be_invoked.UserData); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(1); }
//------------------------------------------------------------------------- public LoaderTicket asyncLoadAsset(string bundle_path, string asset_name, _eAsyncAssetLoadType loader_type, Action <LoaderTicket, string, UnityEngine.Object> loaded_action) { LoaderTicket tick = null; if (loader_type == _eAsyncAssetLoadType.LocalBundleAsset || loader_type == _eAsyncAssetLoadType.LocalRawAsset) { tick = AsyncAssetLoaderMgr.LocalAssetAsyncLoader.getAsset(bundle_path, asset_name, loader_type, loaded_action); } else if (loader_type == _eAsyncAssetLoadType.WWWBundleAsset || loader_type == _eAsyncAssetLoadType.WWWRawAsset) { tick = AsyncAssetLoaderMgr.WWWAssetAsyncLoader.getAsset(bundle_path, asset_name, loader_type, loaded_action); } return(tick); }
//------------------------------------------------------------------------- public LoaderTicket asyncLoadLocalBundle(List <string> list_bundle_path, _eAsyncAssetLoadType loader_type, Action <List <AssetBundle> > loaded_action) { LoaderTicket loader_ticket = new LoaderTicket(); Dictionary <string, AssetBundle> map_needloadab = new Dictionary <string, AssetBundle>(); loader_ticket.MapNeedLoadAssetBundle = map_needloadab; Dictionary <string, AssetBundle> map_loadedab = new Dictionary <string, AssetBundle>(); loader_ticket.MapLoadedAssetBundle = map_loadedab; foreach (var i in list_bundle_path) { AssetBundle asset_bundle = null; if (MapAssetBundle.TryGetValue(i, out asset_bundle)) { map_loadedab[i] = asset_bundle; } else { map_needloadab[i] = null; if (loader_type == _eAsyncAssetLoadType.LocalBundle) { AsyncAssetLoaderMgr.LocalBundleAsyncLoader.getAssetBundle(i, _loadAssetBundleCallBack); } else if (loader_type == _eAsyncAssetLoadType.WWWBundle) { AsyncAssetLoaderMgr.WWWBundleAsyncLoader.getAssetBundle(i, _loadAssetBundleCallBack); } } } if (loader_ticket.MapLoadedAssetBundle.Count == list_bundle_path.Count) { List <AssetBundle> list_bundle = new List <AssetBundle>(); foreach (var i in loader_ticket.MapLoadedAssetBundle) { list_bundle.Add(i.Value); } loaded_action(list_bundle); } else { MapLoaderTicket[loader_ticket] = loaded_action; } return(loader_ticket); }
//------------------------------------------------------------------------- public LoaderTicket getAsset(string asset_path, string asset_name, _eAsyncAssetLoadType loader_type, Action <LoaderTicket, string, UnityEngine.Object> bundle_asset_callback) { LoaderTicket loader_ticket = null; UnityEngine.Object bundle_asset = null; string asset_key = asset_path + asset_name; if (MapBundleAsset.TryGetValue(asset_key, out bundle_asset)) { bundle_asset_callback(loader_ticket, asset_key, bundle_asset); } else { if (loader_type == _eAsyncAssetLoadType.LocalBundleAsset) { if (MapBundle.ContainsKey(asset_path)) { var asset_bundle = MapBundle[asset_path]; bundle_asset = asset_bundle.LoadAsset(asset_name); bundle_asset_callback(loader_ticket, asset_key, bundle_asset); } else { loader_ticket = AsyncAssetLoaderMgr.LocalBundleAsyncLoader.getAssetBundle(asset_path, _loadAssetBundleCallBack); } } else { loader_ticket = AsyncAssetLoaderMgr.WWWAsyncLoader.getIsDoneWWW(asset_path, _loadAssetWWWCallBack); } if (loader_ticket != null) { loader_ticket.UserData = asset_name; Dictionary <LoaderTicket, Action <LoaderTicket, string, UnityEngine.Object> > map_ticketandcallback = null; if (!MapLoaderTicketAndCallBack.TryGetValue(asset_path, out map_ticketandcallback)) { map_ticketandcallback = new Dictionary <LoaderTicket, Action <LoaderTicket, string, UnityEngine.Object> >(); MapLoaderTicketAndCallBack[asset_path] = map_ticketandcallback; } map_ticketandcallback[loader_ticket] = bundle_asset_callback; } } return(loader_ticket); }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { LoaderTicket gen_ret = new LoaderTicket(); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to LoaderTicket constructor!")); }
//------------------------------------------------------------------------- public LoaderTicket getIsDoneWWW(string asset_path, Action <string, WWW> www_isdone_callback) { LoaderTicket loader_ticket = null; WWW www = null; if (MapWWWIsDone.TryGetValue(asset_path, out www)) { if (www.isDone) { www_isdone_callback(asset_path, www); } else { loader_ticket = new LoaderTicket(); Action <string, WWW> ticketandcallback = null; if (!MapLoaderTicketAndCallBack.TryGetValue(asset_path, out ticketandcallback)) { ticketandcallback = www_isdone_callback; MapLoaderTicketAndCallBack[asset_path] = ticketandcallback; } else { ticketandcallback += www_isdone_callback; } //map_ticketandcallback[loader_ticket] = www_isdone_callback; } } else { loader_ticket = new LoaderTicket(); www = new WWW(CasinoHelper.FormalUrlWithRandomVersion(asset_path)); MapWWW[asset_path] = www; Action <string, WWW> ticketandcallback = null; if (!MapLoaderTicketAndCallBack.TryGetValue(asset_path, out ticketandcallback)) { ticketandcallback = www_isdone_callback; MapLoaderTicketAndCallBack[asset_path] = ticketandcallback; } else { ticketandcallback += www_isdone_callback; } } return(loader_ticket); }
//------------------------------------------------------------------------- public LoaderTicket getAssetBundle(string asset_path, Action <string, AssetBundle> asset_bundle_callback) { LoaderTicket loader_ticket = AsyncAssetLoaderMgr.WWWAsyncLoader.getIsDoneWWW(asset_path, _loadAssetBundleWWWCallBack); Action <string, AssetBundle> ticketandcallback = null; if (!MapLoaderTicketAndCallBack.TryGetValue(asset_path, out ticketandcallback)) { ticketandcallback = asset_bundle_callback; MapLoaderTicketAndCallBack[asset_path] = ticketandcallback; } else { ticketandcallback += asset_bundle_callback; } return(loader_ticket); }
public void __Gen_Delegate_Imp37(LoaderTicket p0, UnityEngine.Texture p1) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference); ObjectTranslator translator = luaEnv.translator; translator.Push(L, p0); translator.Push(L, p1); PCall(L, 2, 0, errFunc); LuaAPI.lua_settop(L, errFunc - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
//------------------------------------------------------------------------- // 异步加载WWW下载回来的资源(新) public LoaderTicket LoadWWWAsync(string url, Action <string, WWW> loaded_action) { LoaderTicket tick = AsyncAssetLoaderMgr.WWWAssetAsyncLoader.LoadAsync(url, loaded_action); return(tick); }