Example #1
0
    protected virtual void NewLuaObject()
    {
        string className = Path.GetFileNameWithoutExtension(binder.scriptPath);

        className = className.Substring(0, 1).ToUpper() + className.Substring(1);

        LuaTable clazz             = ScriptManager.Instance.Env[className] as LuaTable;
        LuaTable applicationConfig = ScriptManager.Instance.Env["applicationConfig"] as LuaTable;
        LuaTable gameConfig        = applicationConfig["gameConfig"] as LuaTable;

        try
        {
            if (clazz == null)
            {
                ScriptManager.Instance.DoFile(binder.scriptPath);
            }
            clazz = ScriptManager.Instance.Env[className] as LuaTable;

            luaTable = ScriptHelper.CallFunction(clazz, "new", false) as LuaTable;
            Debug.Log("instance lua script : " + binder.scriptPath);
        }
        catch (System.Exception e)
        {
            Debug.LogError("load lua file failure : " + binder.scriptPath);
        }
    }
    public void ClickButtonDelegete(GameObject go)
    {
        UIWidgetContainer button = GameObjectUtility.FindAndGet <UIButton>("", go);

        if (button == null)
        {
            button = GameObjectUtility.FindAndGet <UIToggle>("", go);
        }
        string btnName = binder.FindReverseButton(button);

        ScriptHelper.CallFunction(luaTable, "clickButton", luaTable, go, btnName);
    }