Exemple #1
0
        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 Hide(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)ToLua.CheckObject(L, 1, typeof(Assets.Script.Frame.LuaPanel));
         obj.Hide();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 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));
     }
 }
 static int IsExistFunc(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);
         bool   o    = obj.IsExistFunc(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_self(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)o;
            object arg0 = ToLua.ToVarObject(L, 2);
            obj.self = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index self on a nil value" : e.Message));
        }
    }
    static int set_luafile(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.luafile = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index luafile on a nil value" : e.Message));
        }
    }
    static int get_self(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)o;
            object ret = obj.self;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index self on a nil value" : e.Message));
        }
    }
    static int get_luafile(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Assets.Script.Frame.LuaPanel obj = (Assets.Script.Frame.LuaPanel)o;
            string ret = obj.luafile;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index luafile on a nil value" : e.Message));
        }
    }