예제 #1
0
        private void OnColorModeSelected()
        {
            if (!EditMode)
            {
                elementsRListSP = EditorGUILayout.BeginScrollView(elementsRListSP);
                elementsRList.DoLayoutList();
                EditorGUILayout.EndScrollView();
                return;
            }
            GUILayout.BeginHorizontal();
            StylesUI.LeftColumn.fixedWidth = Mathf.Clamp(position.width * 0.3f, 50f, 300f);
            GUILayout.BeginVertical(StylesUI.LeftColumn);
            elementsRListSP = EditorGUILayout.BeginScrollView(elementsRListSP);
            elementsRList.DoLayoutList();
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();
            if (!EditMode)
            {
                return;
            }
            GUILayout.BeginVertical();
            if (elementsRList.index != -1 && SelectedCG != null)
            {
                GUILayout.Space(15f);
                GUILayout.BeginVertical("Box");
                GUILayout.Label("Element " + SelectedCG.name, StylesUI.TitleLabel);
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                SelectedCG.name = EditorGUILayout.TextField("Name", SelectedCG.name);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.DuplicateButton, StylesUI.IconButton));
                }))
                {
                    Theme.colors.Add(new ColorGroup(SelectedCG));
                    UpdateColorNames();
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5f);
                GUILayout.Label("Filter Properties", StylesUI.TitleLabel);
                GUILayout.Space(5f);
                // #if UNITY_2017_4_OR_NEWER
                EUIType t = (EUIType)EditorGUILayout.EnumFlagsField("Type", (EUIType)SelectedCG.uiMask, StylesUI.Popup);
                if (t != SelectedCG.uiMask)
                {
                    SelectedCG.uiMask = t;
                    UpdateColors(SelectedCG);
                }
                // #endif
                GUILayout.BeginHorizontal();
                SelectedCG.tag = EditorGUILayout.TagField("Tag", SelectedCG.tag, StylesUI.Popup);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.DeleteTextButton, StylesUI.IconButton));
                }))
                {
                    SelectedCG.tag = "";
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                SelectedCG.regex = EditorGUILayout.TextField("Regex", SelectedCG.regex);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.HelpButton, StylesUI.IconButton));
                }))
                {
                    Application.OpenURL("https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx");
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                GUILayout.EndVertical();

                GUILayout.Space(10f);

                elementRListSP = EditorGUILayout.BeginScrollView(elementRListSP);

                if (colorsList != null)
                {
                    colorsList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (palleteList != null)
                {
                    palleteList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (elementModifierList != null)
                {
                    elementModifierList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (elementDescendantsRList != null)
                {
                    elementDescendantsRList.DoLayoutList();
                }

                EditorGUILayout.EndScrollView();

                GUILayout.BeginHorizontal();
                GameObject prefab = null;
                if (Selection.activeGameObject)
                {
                    #if UNITY_2018_3_OR_NEWER
                    prefab = PrefabUtility.GetOutermostPrefabInstanceRoot(Selection.activeGameObject);
                    #else
                    prefab = PrefabUtility.FindPrefabRoot(Selection.activeGameObject);
                    #endif
                }
                string smartSelection = "Scene";
                if (prefab && AssetDatabase.Contains(prefab))
                {
                    smartSelection = "Prefab";
                }
                else if (Selection.gameObjects.Length > 0)
                {
                    smartSelection = "Selection";
                }
                if (GUILayout.Button("Apply to " + smartSelection))
                {
                    AssignColorGroup(SelectedCG);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }