Пример #1
0
        private static LayerColor LayerColorField(Rect rect, LayerColor layerColor)
        {
            var value = layerColor;
            var rect1 = rect;
            var rect2 = rect;
            var rect3 = rect;
            var rect4 = rect;

            rect1.xMax = rect1.xMin + 175f;
            rect2.xMin = rect1.xMax;
            rect2.xMax = rect2.xMin + 80f;
            rect3.xMin = rect2.xMax;
            rect3.xMax = rect3.xMin + 100;
            rect4.xMin = rect3.xMax;

            value.layer = EditorGUI.LayerField(rect1, value.layer);
            value.layer = EditorGUI.DelayedIntField(rect2, value.layer);
            value.color = EditorGUI.ColorField(rect3, value.color);
            value.mode  = (TintMode)EditorGUI.EnumPopup(rect4, value.mode);

            if (value.layer > 31 || value.layer < 0)
            {
                return(layerColor);
            }

            return(value);
        }
Пример #2
0
        public static void ReloadPrefs()
        {
            Enabled                         = new PrefItem <bool>("Enabled", true, string.Format("Enabled ({0}+H)", Utility.CtrlKey), "Enable or disable the entire plugin, it will be automatically disabled if any error occurs");
            Offset                          = new PrefItem <int>("Offset", 2, "Offset", "Offset for icons, useful if you have more extensions that also uses hierarchy");
            Tree                            = new PrefItem <bool>("Tree", true, "Hierarchy tree", "Shows lines connecting child transforms to their parent, useful if you have multiple childs inside childs");
            Tooltips                        = new PrefItem <bool>("Tooltip", true, "Tooltips", "Shows tooltips, like this one");
            RelevantTooltipsOnly            = new PrefItem <bool>("RelevantTooltips", true, "Relevant Tooltips", "Show only tooltips with relevant informations");
            EnhancedSelection               = new PrefItem <bool>("Selection", true, "Enhanced selection", "Allow selecting GameObjects by dragging over them with right mouse button");
            LeftSideButton                  = new PrefItem <RightSideIcon>("LeftSideButton", new Icons.GameObjectIcon(), "Left side button", "The button that will appear in the left side of the hierarchy\nLooks better with \"Hierarchy Tree\" disabled");
            LeftmostButton                  = new PrefItem <bool>("LeftmostSideButton", true, "Left side button at leftmost", "Put the left button to the leftmost side of the hierachy, if disabled it will be next to the game object name");
            MiniLabelType                   = new PrefItem <MiniLabelType>("MiniLabel", global::EnhancedHierarchy.MiniLabelType.TagAndLayer, "Mini label", "The little label next to the GameObject name");
            Trailing                        = new PrefItem <bool>("Trailing", true, "Trailing", "Append ... when names are bigger than the view area");
            AllowSelectingLocked            = new PrefItem <bool>("SelectLocked", true, "Allow locked selection (Hierarchy)", "Allow selecting objects that are locked");
            AllowSelectingLockedSceneView   = new PrefItem <bool>("SelectLockedSV", false, "Allow locked selection (Scene View)", "Allow selecting objects that are locked on scene view\nObjects locked before you change this option will have the previous behaviour, you need to unlock and lock them again to apply this setting");
            ChangeAllSelected               = new PrefItem <bool>("ChangeAllLocked", true, "Change all selected", "This will make the enable, lock, layer, tag and static buttons affect all selected objects in the hierarchy");
            NumericChildExpand              = new PrefItem <bool>("ReplaceToggle", false, "Replace default child toggle", "Replace the default toggle for expanding children for a new one that shows the child count");
            SmallerMiniLabel                = new PrefItem <bool>("SmallerMiniLabel", true, "Smaller font", "Use a smaller font on the minilabel for narrow hierarchies");
            CentralizeMiniLabelWhenPossible = new PrefItem <bool>("CentralizeWhenPossible", true, "Centralize when possible", "Centralize minilabel when there's only tag or only layer on it");
            HideDefaultLayer                = new PrefItem <bool>("HideDefaultLayer", true, "Hide \"Default\" layer", "Hide default layer on minilabel");
            HideDefaultTag                  = new PrefItem <bool>("HideDefaultTag", true, "Hide \"Untagged\" tag", "Hide default tag on minilabel");
            HideDefaultIcon                 = new PrefItem <bool>("HideDefaultIcon", false, "Hide default icon", "Hide the default game object icon");

            StaticAskMode = new PrefItem <ChildrenChangeMode>("StaticMode", ChildrenChangeMode.Ask, "Static", "Which flags will be changed when you click on the static toggle");
            IconAskMode   = new PrefItem <ChildrenChangeMode>("IconAskMode", ChildrenChangeMode.ObjectOnly, "Icon", "Which objects will have their icon changed when you click on the icon button");
            LockAskMode   = new PrefItem <ChildrenChangeMode>("LockMode", ChildrenChangeMode.ObjectAndChildren, "Lock", "Which objects will be locked when you click on the lock toggle");
            LayerAskMode  = new PrefItem <ChildrenChangeMode>("LayerMode", ChildrenChangeMode.Ask, "Layer", "Which objects will have their layer changed when you click on the layer button or on the mini label");
            TagAskMode    = new PrefItem <ChildrenChangeMode>("TagMode", ChildrenChangeMode.ObjectOnly, "Tag", "Which objects will have their tag changed when you click on the tag button or on the mini label");

            LineSize     = new PrefItem <int>("LineSize", 1, "Line thickness", "Separator line thickness");
            LineColor    = new PrefItem <Color>("LineColor", DefaultLineColor, "Line color", "The color used on separators line");
            OddRowColor  = new PrefItem <Color>("OddRow", DefaultOddSortColor, "Odd row color", "The color used on odd rows");
            EvenRowColor = new PrefItem <Color>("EvenRow", DefaultEvenSortColor, "Even row color", "The color used on even rows");

            var defaultLeftIcons   = new LeftSideIcon[] { new Icons.MonoBehaviourIcon(), new Icons.Warnings(), new Icons.SoundIcon() };
            var defaultRightIcons  = new RightSideIcon[] { new Icons.Active(), new Icons.Lock(), new Icons.Static(), new Icons.PrefabApply() };
            var defaultLayerColors = new LayerColor[] { new LayerColor(5, new Color(0.8f, 0f, 1f, EditorGUIUtility.isProSkin ? 0.1f : 0.145f)) };

            LeftIcons         = new PrefItem <LeftSideIcon[]>("LeftIcons", defaultLeftIcons, "Left Side Icons", "The icons that appear next to the game object name");
            RightIcons        = new PrefItem <RightSideIcon[]>("RightIcons", defaultRightIcons, "Right Side Icons", "The icons that appear to the rightmost of the hierarchy");
            PerLayerRowColors = new PrefItem <LayerColor[]>("PerLayerRowColors", defaultLayerColors, "Per layer row color", "Set a row color for each different layer");

            leftIconsList  = GenerateReordableListForIcons(LeftIcons);
            rightIconsList = GenerateReordableListForIcons(RightIcons);

            rowColorsList                       = GenerateReordableListForIcons(PerLayerRowColors);
            rowColorsList.draggable             = false;
            rowColorsList.onAddDropdownCallback = null;

            rowColorsList.drawElementCallback = (rect, index, focused, active) => {
                rect.xMin -= EditorGUI.indentLevel * 16f;

                var value = (LayerColor)rowColorsList.list[index];
                var rect1 = rect;
                var rect2 = rect;
                var rect3 = rect;

                rect1.xMax = rect1.xMin + 175f;
                rect2.xMin = rect1.xMax;
                rect2.xMax = rect2.xMin + 80f;
                rect3.xMin = rect2.xMax;

                value.layer = EditorGUI.LayerField(rect1, value.layer);
                value.layer = EditorGUI.IntField(rect2, value.layer);
                value.color = EditorGUI.ColorField(rect3, value.color);

                if (value.layer > 31 || value.layer < 0)
                {
                    value.layer = 0;
                }

                rowColorsList.list[index] = value;
            };
        }