private void DrawGlobalSettings()
        {
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.LabelField("Features", EditorStyles.boldLabel);

                HierarchyDecoratorGUI.ToggleAuto(ref t.showActiveToggles, "Show GameObject Toggles");
                HierarchyDecoratorGUI.ToggleAuto(ref t.showComponents, "Show Common Components");
                HierarchyDecoratorGUI.ToggleAuto(ref t.showLayers, "Show Current Layer");

                EditorGUILayout.LabelField("Style", EditorStyles.boldLabel);

                t.globalStyle.OnDraw();
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorApplication.RepaintHierarchyWindow();
            }
        }
コード例 #2
0
 public void OnDraw()
 {
     HierarchyDecoratorGUI.ToggleAuto(ref twoToneBackground, "Show Two Tone Background");
 }
        public override void OnInspectorGUI()
        {
            if (prefixes == null)
            {
                prefixes = serializedObject.FindProperty("prefixes");
                styles   = serializedObject.FindProperty("styles");

                GetSettingNames();
            }

            if (serializedObject == null)
            {
                return;
            }

            serializedObject.UpdateIfRequiredOrScript();


            verticalStyle = new GUIStyle(GUI.skin.window)
            {
                padding = new RectOffset(0, 0, 10, 10),

                fontSize = 10
            };

            GUIStyle greyMid = new GUIStyle(EditorStyles.centeredGreyMiniLabel)
            {
                fontSize  = 12,
                fontStyle = FontStyle.Bold,
            };

            EditorGUILayout.BeginVertical(verticalStyle);
            {
                tabSelection = GUILayout.SelectionGrid(tabSelection, tabNames, tabNames.Length / 2, greyMid);

                if (tabSelection != 4)
                {
                    EditorGUILayout.Space();
                    HierarchyDecoratorGUI.LineSpacer();
                    EditorGUILayout.Space();
                }

                switch (tabSelection)
                {
                case 0:
                    DrawGlobalSettings();
                    break;

                case 1:
                    prefixSelection = GUILayout.SelectionGrid(prefixSelection, prefixNames.ToArray(), 3, EditorStyles.centeredGreyMiniLabel);
                    break;

                case 2:
                    styleSelection = GUILayout.SelectionGrid(styleSelection, styleNames.ToArray(), 3, EditorStyles.centeredGreyMiniLabel);
                    break;

                case 3:
                    String[] catergories = componentCatergories.Keys.ToArray();
                    catSelection      = GUILayout.SelectionGrid(catSelection, catergories, 4, EditorStyles.centeredGreyMiniLabel);
                    currentComponents = componentCatergories[catergories[catSelection]];
                    break;

                case 4:
                    break;
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUI.indentLevel++;
            switch (tabSelection)
            {
            case 0:

                break;

            case 1:
                DrawSetting("Prefix Selection", ref prefixSelection, prefixNames.ToArray(), prefixes);
                break;

            case 2:
                DrawSetting("Style Selection", ref styleSelection, styleNames.ToArray(), styles);
                break;

            case 3:
                DrawComponentSelection();
                break;

            case 4:
                Texture  banner = Textures.Banner;
                GUIStyle style  = new GUIStyle();

                if (GUILayout.Button("GitHub Repository", EditorStyles.miniButtonMid))
                {
                    Application.OpenURL("https://github.com/WooshiiDev/HierarchyDecorator/");
                }

                if (GUILayout.Button("Twitter", EditorStyles.miniButtonMid))
                {
                    Application.OpenURL("https://twitter.com/DaamiaanS");
                }

                GUILayout.Box(banner, style);
                break;

            default:
                break;
            }
            EditorGUI.indentLevel--;
        }
        private void DrawSetting(string label, ref int selection, string[] selectionArray, SerializedProperty property)
        {
            int localSelection = selection;

            if (property.arraySize == 0)
            {
                HierarchyDecoratorGUI.ButtonAction("Add New", EditorStyles.toolbarButton, () =>
                {
                    property.InsertArrayElementAtIndex(property.arraySize);

                    serializedObject.ApplyModifiedProperties();
                    serializedObject.Update();

                    GetSettingNames();
                    HierarchyDecorator.GetSettings();

                    localSelection = property.arraySize - 1;
                });

                selection = localSelection;
            }

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                //Draw buttons
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField(label, EditorStyles.largeLabel);


                    EditorGUI.BeginChangeCheck();
                    {
                        HierarchyDecoratorGUI.ButtonAction("Add New", EditorStyles.miniButton, () =>
                        {
                            property.InsertArrayElementAtIndex(property.arraySize);

                            serializedObject.ApplyModifiedProperties();
                            serializedObject.Update();

                            GetSettingNames();
                            HierarchyDecorator.GetSettings();

                            localSelection = property.arraySize - 1;
                        });

                        HierarchyDecoratorGUI.ButtonAction("Remove Current", EditorStyles.miniButton, () =>
                        {
                            property.DeleteArrayElementAtIndex(localSelection);

                            serializedObject.ApplyModifiedProperties();
                            serializedObject.Update();

                            GetSettingNames();
                            HierarchyDecorator.GetSettings();

                            localSelection--;
                        });
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        selection = localSelection;
                    }
                }
                EditorGUILayout.EndHorizontal();

                //Draw current setting, and update when changed
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(property.GetArrayElementAtIndex(selection));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorApplication.RepaintHierarchyWindow();
                    property.serializedObject.ApplyModifiedProperties();
                }
            }
            EditorGUILayout.EndVertical();
        }