Exemple #1
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();
            }
        }