Exemplo n.º 1
0
    public static void CreatUIbyLua(string UIWindowName, UIType UIType, UILayerManager UILayerManager, bool isAutoCreatePrefab)
    {
        GameObject uiGo = new GameObject(UIWindowName);

        UIWindowLuaHelper uiBaseTmp = uiGo.AddComponent <UIWindowLuaHelper>();

        uiGo.layer = LayerMask.NameToLayer("UI");

        uiBaseTmp.m_UIType = UIType;

        uiGo.AddComponent <Canvas>();
        uiGo.AddComponent <GraphicRaycaster>();

        RectTransform ui = uiGo.GetComponent <RectTransform>();

        ui.sizeDelta = Vector2.zero;
        ui.anchorMin = Vector2.zero;
        ui.anchorMax = Vector2.one;

        GameObject BgGo = new GameObject("BG");

        BgGo.layer = LayerMask.NameToLayer("UI");
        RectTransform Bg = BgGo.AddComponent <RectTransform>();

        Bg.SetParent(ui);
        Bg.sizeDelta = Vector2.zero;
        Bg.anchorMin = Vector2.zero;
        Bg.anchorMax = Vector2.one;

        GameObject rootGo = new GameObject("root");

        rootGo.layer = LayerMask.NameToLayer("UI");
        RectTransform root = rootGo.AddComponent <RectTransform>();

        root.SetParent(ui);
        root.sizeDelta = Vector2.zero;
        root.anchorMin = Vector2.zero;
        root.anchorMax = Vector2.one;

        uiBaseTmp.m_bgMask = BgGo;
        uiBaseTmp.m_uiRoot = rootGo;

        if (UILayerManager)
        {
            UILayerManager.SetLayer(uiBaseTmp);
        }

        if (isAutoCreatePrefab)
        {
            string Path = "Resources/UI/" + UIWindowName + "/" + UIWindowName + ".prefab";
            FileTool.CreatFilePath(Application.dataPath + "/" + Path);
            PrefabUtility.CreatePrefab("Assets/" + Path, uiGo, ReplacePrefabOptions.ConnectToPrefab);
        }

        ProjectWindowUtil.ShowCreatedAsset(uiGo);
    }
Exemplo n.º 2
0
 static int OnHide(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIWindowLuaHelper obj = (UIWindowLuaHelper)ToLua.CheckObject(L, 1, typeof(UIWindowLuaHelper));
         obj.OnHide();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int SetText(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UIWindowLuaHelper obj  = (UIWindowLuaHelper)ToLua.CheckObject(L, 1, typeof(UIWindowLuaHelper));
         string            arg0 = ToLua.CheckString(L, 2);
         string            arg1 = ToLua.CheckString(L, 3);
         obj.SetText(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int SetTextByLangeage(IntPtr L)
 {
     try
     {
         int count              = LuaDLL.lua_gettop(L);
         UIWindowLuaHelper obj  = (UIWindowLuaHelper)ToLua.CheckObject(L, 1, typeof(UIWindowLuaHelper));
         string            arg0 = ToLua.CheckString(L, 2);
         string            arg1 = ToLua.CheckString(L, 3);
         object[]          arg2 = ToLua.ToParamsObject(L, 4, count - 3);
         obj.SetTextByLangeage(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 5
0
    static int EnterAnim(IntPtr L)
    {
        try
        {
            int count                   = LuaDLL.lua_gettop(L);
            UIWindowLuaHelper obj       = (UIWindowLuaHelper)ToLua.CheckObject(L, 1, typeof(UIWindowLuaHelper));
            UIAnimCallBack    arg0      = null;
            LuaTypes          funcType2 = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (UIAnimCallBack)ToLua.CheckObject(L, 2, typeof(UIAnimCallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg0 = DelegateFactory.CreateDelegate(typeof(UIAnimCallBack), func) as UIAnimCallBack;
            }

            UICallBack arg1      = null;
            LuaTypes   funcType3 = LuaDLL.lua_type(L, 3);

            if (funcType3 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (UICallBack)ToLua.CheckObject(L, 3, typeof(UICallBack));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 3);
                arg1 = DelegateFactory.CreateDelegate(typeof(UICallBack), func) as UICallBack;
            }

            object[] arg2 = ToLua.ToParamsObject(L, 4, count - 3);
            System.Collections.IEnumerator o = obj.EnterAnim(arg0, arg1, arg2);
            ToLua.Push(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }