void SetClickFunction(string funcName, bool withParam = false) { Button btn = GetComponent<Button>(); LuaPanel luaPanel = container.GetComponent<LuaPanel>(); if (luaPanel) { btn.onClick.AddListener(delegate () { luaPanel.Call(funcName); }); } else { PanelBase panel = container.GetComponent<PanelBase>(); MethodInfo info = panel.GetType().GetMethod(funcName); if (info != null) { object[] param = withParam ? new object[] { gameObject } : null; btn.onClick.AddListener(delegate () { info.Invoke(panel, param); }); } else { Debug.LogWarning(string.Format("The function {0} is hasn't been found in {1}.", funcName, name)); } } }
static int Call(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)ToLua.CheckObject(L, 1, typeof(Assets.Script.Frame.LuaPanel)); string arg0 = ToLua.CheckString(L, 2); obj.Call(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }