Exemple #1
0
    void CreateUIGUI()
    {
        EditorGUI.indentLevel = 0;
        isFoldCreateUI        = EditorGUILayout.Foldout(isFoldCreateUI, "创建UI:");

        if (isFoldCreateUI)
        {
            EditorGUI.indentLevel = 1;
            EditorGUILayout.LabelField("提示: 脚本和 UI 名称会自动添加Window后缀");
            m_uiName = EditorGUILayout.TextField("UI Name:", m_uiName);
            m_UIType = (UIType)EditorGUILayout.EnumPopup("UI Type:", m_UIType);

            isAutoCreatePrefab = EditorGUILayout.Toggle("自动生成 Prefab", isAutoCreatePrefab);

            var l_nameTmp = m_uiName + "Window";
            if (!string.IsNullOrEmpty(m_uiName))
            {
                var l_typeTmp = EditorTool.GetType(l_nameTmp);
                if (l_typeTmp != null)
                {
                    if (l_typeTmp.BaseType.Equals(typeof(UIWindowBase)))
                    {
                        if (GUILayout.Button("创建UI"))
                        {
                            UICreateService.CreatUI(l_nameTmp, m_UIType, m_UILayerManager, isAutoCreatePrefab);
                            m_uiName = "";
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("该类没有继承UIWindowBase");
                    }
                }
                else
                {
                    if (GUILayout.Button("创建UI脚本"))
                    {
                        UICreateService.CreatUIScript(l_nameTmp);
                    }
                }
            }
        }
    }
    void CreateUIGUI()
    {
        EditorGUI.indentLevel = 0;
        isFoldCreateUI        = EditorGUILayout.Foldout(isFoldCreateUI, "创建UI:");

        if (isFoldCreateUI)
        {
            cameraKeyList = UIManager.GetCameraNames();

            EditorGUI.indentLevel = 1;
            EditorGUILayout.LabelField("提示: 脚本和 UI 名称会自动添加Window后缀");
            m_UIname = EditorGUILayout.TextField("UI Name:", m_UIname);

            m_UICameraKeyIndex = EditorGUILayout.Popup("Camera", m_UICameraKeyIndex, cameraKeyList);

            m_UIType = (UIType)EditorGUILayout.EnumPopup("UI Type:", m_UIType);

            isUseLua = EditorGUILayout.Toggle("使用 Lua", isUseLua);
            if (isUseLua)
            {
                EditorGUI.indentLevel++;
                isAutoCreateLuaFile = EditorGUILayout.Toggle("自动创建Lua脚本", isAutoCreateLuaFile);
                EditorGUI.indentLevel--;
            }

            isAutoCreatePrefab = EditorGUILayout.Toggle("自动生成 Prefab", isAutoCreatePrefab);

            if (m_UIname != "")
            {
                string l_nameTmp = m_UIname + "Window";

                if (!isUseLua)
                {
                    Type l_typeTmp = EditorTool.GetType(l_nameTmp);
                    if (l_typeTmp != null)
                    {
                        if (l_typeTmp.BaseType.Equals(typeof(UIWindowBase)))
                        {
                            if (GUILayout.Button("创建UI"))
                            {
                                UICreateService.CreatUI(l_nameTmp, cameraKeyList[m_UICameraKeyIndex], m_UIType, m_UILayerManager, isAutoCreatePrefab);
                                m_UIname = "";
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField("该类没有继承UIWindowBase");
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("创建UI脚本"))
                        {
                            UICreateService.CreatUIScript(l_nameTmp);
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("创建UI"))
                    {
                        UICreateService.CreatUIbyLua(l_nameTmp, m_UIType, m_UILayerManager, isAutoCreatePrefab);
                        if (isAutoCreateLuaFile)
                        {
                            UICreateService.CreatUILuaScript(l_nameTmp);
                        }

                        m_UIname = "";
                    }
                }
            }
        }
    }