private static void OnPreferencesGUI(string search)
        {
            scroll = EditorGUILayout.BeginScrollView(scroll, false, false);

            EditorGUILayout.Separator();
            Enabled.DoGUI();
            EditorGUILayout.Separator();
            EditorGUILayout.HelpBox("Each item has a tooltip explaining what it does, keep the mouse over it to see.", MessageType.Info);
            EditorGUILayout.Separator();

            using (Enabled.GetEnabledScope()) {
                using (new GUIIndent("Misc settings")) {
                    using (new GUIIndent("Margins")) {
                        RightMargin.DoGUISlider(-50, 50);
                        using (new GUIEnabled(Reflected.HierarchyArea.Supported)) {
                            LeftMargin.DoGUISlider(-50, 50);
                            Indent.DoGUISlider(0, 35);
                        }
                        if (!Reflected.HierarchyArea.Supported)
                        {
                            EditorGUILayout.HelpBox("Custom Indent and Margins are not supported in this Unity version", MessageType.Warning);
                        }
                    }

                    TreeOpacity.DoGUISlider(0f, 1f);

                    using (new GUIIndent())
                        using (SelectOnTree.GetFadeScope(TreeOpacity.Value > 0.01f))
                            SelectOnTree.DoGUI();

                    Tooltips.DoGUI();

                    using (new GUIIndent())
                        using (RelevantTooltipsOnly.GetFadeScope(Tooltips))
                            RelevantTooltipsOnly.DoGUI();

                    if (EnhancedSelectionSupported)
                    {
                        EnhancedSelection.DoGUI();
                    }

                    Trailing.DoGUI();
                    ChangeAllSelected.DoGUI();
                    NumericChildExpand.DoGUI();

                    using (new GUIEnabled(Reflected.IconWidthSupported))
                        DisableNativeIcon.DoGUI();

                    using (HideDefaultIcon.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon())))
                        HideDefaultIcon.DoGUI();

                    using (OpenScriptsOfLogs.GetFadeScope(IsButtonEnabled(new Icons.Warnings())))
                        OpenScriptsOfLogs.DoGUI();

                    GUI.changed = false;

                    using (AllowSelectingLocked.GetFadeScope(IsButtonEnabled(new Icons.Lock())))
                        AllowSelectingLocked.DoGUI();

                    using (AllowSelectingLockedSceneView.GetFadeScope(IsButtonEnabled(new Icons.Lock()) && AllowSelectingLocked))
                        AllowSelectingLockedSceneView.DoGUI();

                    if (GUI.changed && EditorUtility.DisplayDialog("Relock all objects",
                                                                   "Would you like to relock all objects?\n" +
                                                                   "This is recommended when changing this setting and might take a few seconds on large scenes" +
                                                                   "\nIt's also recommended to do this on all scenes", "Yes", "No"))
                    {
                        Utility.RelockAllObjects();
                    }

                    HoverTintColor.DoGUI();
                }

                using (new GUIIndent("Row separators")) {
                    LineSize.DoGUISlider(0, 6);

                    using (LineColor.GetFadeScope(LineSize > 0))
                        LineColor.DoGUI();

                    OddRowColor.DoGUI();
                    EvenRowColor.DoGUI();

                    GUI.changed = false;
                    var rect = EditorGUILayout.GetControlRect(false, rowColorsList.GetHeight());
                    rect.xMin += EditorGUI.indentLevel * 16f;
                    rowColorsList.DoList(rect);
                }

                MiniLabel.DoGUI();
                using (new GUIIndent()) {
                    using (SmallerMiniLabel.GetFadeScope(MiniLabel.Value != MiniLabelType.None))
                        SmallerMiniLabel.DoGUI();
                    using (HideDefaultTag.GetFadeScope(MiniLabelTagEnabled))
                        HideDefaultTag.DoGUI();
                    using (HideDefaultLayer.GetFadeScope(MiniLabelLayerEnabled))
                        HideDefaultLayer.DoGUI();
                    using (CentralizeMiniLabelWhenPossible.GetFadeScope((HideDefaultLayer || HideDefaultTag) && (MiniLabel.Value == MiniLabelType.TagAndLayer || MiniLabel.Value == MiniLabelType.LayerAndTag)))
                        CentralizeMiniLabelWhenPossible.DoGUI();
                }

                LeftSideButtonPref.DoGUI();
                using (new GUIIndent())
                    using (LeftmostButton.GetFadeScope(LeftSideButton != IconBase.none))
                        LeftmostButton.DoGUI();

                using (new GUIIndent("Children behaviour on change")) {
                    using (LockAskMode.GetFadeScope(IsButtonEnabled(new Icons.Lock())))
                        LockAskMode.DoGUI();
                    using (LayerAskMode.GetFadeScope(IsButtonEnabled(new Icons.Layer()) || MiniLabelLayerEnabled))
                        LayerAskMode.DoGUI();
                    using (TagAskMode.GetFadeScope(IsButtonEnabled(new Icons.Tag()) || MiniLabelTagEnabled))
                        TagAskMode.DoGUI();
                    using (StaticAskMode.GetFadeScope(IsButtonEnabled(new Icons.Static())))
                        StaticAskMode.DoGUI();
                    using (IconAskMode.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon())))
                        IconAskMode.DoGUI();

                    EditorGUILayout.HelpBox(string.Format("Pressing down {0} while clicking on a button will make it temporary have the opposite children change mode", Utility.CtrlKey), MessageType.Info);
                }

                leftIconsList.displayAdd = LeftIconsMenu.GetItemCount() > 0;
                leftIconsList.DoLayoutList();

                rightIconsList.displayAdd = RightIconsMenu.GetItemCount() > 0;
                rightIconsList.DoLayoutList();

                EditorGUILayout.HelpBox("Alt + Click on child expand toggle makes it expand all the grandchildren too", MessageType.Info);

                if (IsButtonEnabled(new Icons.Memory()))
                {
                    EditorGUILayout.HelpBox("\"Memory Used\" may create garbage and consequently framerate stutterings, leave it disabled if maximum performance is important for your project", MessageType.Warning);
                }

                if (IsButtonEnabled(new Icons.Lock()))
                {
                    EditorGUILayout.HelpBox("Remember to always unlock your game objects when removing or disabling this extension, as you won't be able to unlock without it and may lose scene data", MessageType.Warning);
                }

                GUI.enabled = true;
                EditorGUILayout.EndScrollView();

                using (new EditorGUILayout.HorizontalScope()) {
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.LabelField(versionContent, GUILayout.Width(170f));
                }

                using (new EditorGUILayout.HorizontalScope()) {
                    if (GUILayout.Button(resetSettingsContent, GUILayout.Width(120f)))
                    {
                        onResetPreferences();
                    }

                    if (GUILayout.Button(unlockAllContent, GUILayout.Width(120f)))
                    {
                        Utility.UnlockAllObjects();
                    }

                    if (GUILayout.Button(mailDeveloperContent, GUILayout.Width(120f)))
                    {
                        OpenSupportEmail();
                    }
                }

                EditorGUILayout.Separator();
                Styles.ReloadTooltips();
                EditorApplication.RepaintHierarchyWindow();
            }
        }
Beispiel #2
0
        private static void OnPreferencesGUI()
        {
            scroll.Value = EditorGUILayout.BeginScrollView(scroll, false, false);

            EditorGUILayout.Separator();

            Enabled.DoGUI();
            EditorGUILayout.Separator();

            using (Enabled.GetEnabledScope()) {
                using (new GUIIndent("Misc settings")) {
                    Offset.DoGUI();
                    Tree.DoGUI();
                    Tooltips.DoGUI();
                    using (RelevantTooltipsOnly.GetFadeScope(Tooltips))
                        RelevantTooltipsOnly.DoGUI();
                    EnhancedSelection.DoGUI();
                    Trailing.DoGUI();
                    ChangeAllSelected.DoGUI();
                    NumericChildExpand.DoGUI();

                    using (HideDefaultIcon.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon())))
                        HideDefaultIcon.DoGUI();

                    GUI.changed = false;

                    using (AllowSelectingLocked.GetFadeScope(IsButtonEnabled(new Icons.Lock())))
                        AllowSelectingLocked.DoGUI();

                    using (AllowSelectingLockedSceneView.GetFadeScope(IsButtonEnabled(new Icons.Lock()) && AllowSelectingLocked))
                        AllowSelectingLockedSceneView.DoGUI();

                    if (GUI.changed && EditorUtility.DisplayDialog("Relock all objects",
                                                                   "Would you like to relock all objects?\n" +
                                                                   "This is recommended when changing this setting and might take a few seconds on large scenes" +
                                                                   "\nIt's also recommended to do this on all scenes", "Yes", "No"))
                    {
                        Utility.RelockAllObjects();
                    }
                }

                using (new GUIIndent("Row separators")) {
                    LineSize.DoSlider(0, 6);

                    using (LineColor.GetFadeScope(LineSize > 0))
                        LineColor.DoGUI();

                    OddRowColor.DoGUI();
                    EvenRowColor.DoGUI();

                    GUI.changed = false;
                    var rect = EditorGUILayout.GetControlRect(false, rowColorsList.GetHeight());
                    rect.xMin += EditorGUI.indentLevel * 16f;
                    rowColorsList.DoList(rect);

                    if (GUI.changed)
                    {
                        PerLayerRowColors.Value = rowColorsList.list.Cast <LayerColor>().ToArray();
                    }
                }

                using (new GUIIndent(MiniLabelType)) {
                    using (SmallerMiniLabel.GetFadeScope(MiniLabelType.Value != global::EnhancedHierarchy.MiniLabelType.None))
                        SmallerMiniLabel.DoGUI();
                    using (HideDefaultTag.GetFadeScope(MiniLabelTagEnabled))
                        HideDefaultTag.DoGUI();
                    using (HideDefaultLayer.GetFadeScope(MiniLabelLayerEnabled))
                        HideDefaultLayer.DoGUI();
                    using (CentralizeMiniLabelWhenPossible.GetFadeScope((HideDefaultLayer || HideDefaultTag) && (MiniLabelType.Value == global::EnhancedHierarchy.MiniLabelType.TagAndLayer || MiniLabelType.Value == global::EnhancedHierarchy.MiniLabelType.LayerAndTag)))
                        CentralizeMiniLabelWhenPossible.DoGUI();
                }

                using (new GUIIndent(LeftSideButton))
                    using (LeftmostButton.GetFadeScope(LeftSideButton.Value != new Icons.RightNone()))
                        LeftmostButton.DoGUI();

                using (new GUIIndent("Children behaviour on change")) {
                    using (LockAskMode.GetFadeScope(IsButtonEnabled(new Icons.Lock())))
                        LockAskMode.DoGUI();
                    using (LayerAskMode.GetFadeScope(IsButtonEnabled(new Icons.Layer()) || MiniLabelLayerEnabled))
                        LayerAskMode.DoGUI();
                    using (TagAskMode.GetFadeScope(IsButtonEnabled(new Icons.Tag()) || MiniLabelTagEnabled))
                        TagAskMode.DoGUI();
                    using (StaticAskMode.GetFadeScope(IsButtonEnabled(new Icons.Static())))
                        StaticAskMode.DoGUI();
                    using (IconAskMode.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon())))
                        IconAskMode.DoGUI();

                    EditorGUILayout.HelpBox(string.Format("Tip: Pressing down {0} while clicking on a button will make it temporary have the opposite children change mode", Utility.CtrlKey), MessageType.Info);
                }

                leftIconsList.displayAdd = LeftIconsMenu.GetItemCount() > 0;
                leftIconsList.DoLayoutList();
                LeftIcons.Value = leftIconsList.list.Cast <LeftSideIcon>().ToArray();

                rightIconsList.displayAdd = RightIconsMenu.GetItemCount() > 0;
                rightIconsList.DoLayoutList();
                RightIcons.Value = rightIconsList.list.Cast <RightSideIcon>().ToArray();

                if (IsButtonEnabled(new Icons.Lock()))
                {
                    EditorGUILayout.HelpBox("Remember to always unlock your game objects when removing or disabling this extension, as you won't be able to unlock without it and may lose scene data", MessageType.Warning);
                }

                GUI.enabled = true;
                EditorGUILayout.EndScrollView();
                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button(resetSettingsContent, GUILayout.Width(120f)))
                {
                    DeleteSavedValues();
                }
                if (GUILayout.Button(unlockAllContent, GUILayout.Width(120f)))
                {
                    Utility.UnlockAllObjects();
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Separator();

                Styles.ReloadTooltips();
                EditorApplication.RepaintHierarchyWindow();
            }
        }