/// <summary> /// Page GameObject Name 必须和LuaLogic的文件名一致,避免不必要的配置 /// </summary> /// <param name="pagePath"></param> /// <param name="param"></param> public void Show(string pagePath, object param = null) { if (!cachePagePool.ContainsKey(pagePath)) { new Promise <LoadOperation>((s, j) => { LoadOperation loader = GResource.LoadAssetAsync(pagePath); loader.OnFinish += s; AppInter.StartCoroutine(loader); }).Then((loader) => { GameObject prefab = loader.GetAsset <GameObject>(); GameObject gObj = GameObject.Instantiate(prefab); gObj.name = Path.GetFileNameWithoutExtension(pagePath); LuaPageBehaviour pageBehaviour = gObj.AddComponent <LuaPageBehaviour>(); UIPage page = new UIPage(pageBehaviour, pagePath); //缓存记录 cachePagePool.Add(pagePath, page); showUIPage(page, param); }).Catch((e) => { Debug.LogError("加载Page异常! Path:" + pagePath); Debug.LogException(e); }); } else { UIPage page = cachePagePool[pagePath]; showUIPage(page, param); } }
public UIPage(LuaPageBehaviour luaBehaviour, string pagePath) { pageRoot = UIPageRoot.Instance; context = new PageContext(); this.luaBehaviour = luaBehaviour; context.assetPath = pagePath; context.pageName = Path.GetFileNameWithoutExtension(pagePath); cacheGameObj = luaBehaviour.gameObject; cacheTrans = cacheGameObj.transform; }
static int OnDestroy(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); LuaPageBehaviour obj = (LuaPageBehaviour)ToLua.CheckObject(L, 1, typeof(LuaPageBehaviour)); obj.OnDestroy(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddClick(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); LuaPageBehaviour obj = (LuaPageBehaviour)ToLua.CheckObject(L, 1, typeof(LuaPageBehaviour)); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject)); LuaFunction arg1 = ToLua.CheckLuaFunction(L, 3); obj.AddClick(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int OnShow(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); LuaPageBehaviour obj = (LuaPageBehaviour)ToLua.CheckObject(L, 1, typeof(LuaPageBehaviour)); UIPage arg0 = (UIPage)ToLua.CheckObject(L, 2, typeof(UIPage)); object arg1 = ToLua.ToVarObject(L, 3); obj.OnShow(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_Name(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); LuaPageBehaviour obj = (LuaPageBehaviour)o; string ret = obj.Name; LuaDLL.lua_pushstring(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Name on a nil value" : e.Message)); } }
static int _CreateUIPage(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { LuaPageBehaviour arg0 = (LuaPageBehaviour)ToLua.CheckUnityObject(L, 1, typeof(LuaPageBehaviour)); string arg1 = ToLua.CheckString(L, 2); UIPage obj = new UIPage(arg0, arg1); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UIPage.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }