Exemplo n.º 1
0
        static Preferences()
        {
            InitializePreferences();

            Enabled.Label.text = string.Format("Enabled ({0}+H)", Utility.CtrlKey);

#if UNITY_2018_3_OR_NEWER
            LeftSideButtonPref.DefaultValue = new IconData()
            {
                Icon = new Icons.None()
            };
#else
            LeftSideButtonPref.DefaultValue = new IconData()
            {
                Icon = new Icons.GameObjectIcon()
            };
#endif

            LineColor.DefaultValue      = DefaultLineColor;
            OddRowColor.DefaultValue    = DefaultOddSortColor;
            EvenRowColor.DefaultValue   = DefaultEvenSortColor;
            HoverTintColor.DefaultValue = DefaultHoverTint;

            var defaultLeftIcons = new IconList {
                new Icons.MonoBehaviourIcon(), new Icons.Warnings(), new Icons.SoundIcon()
            };
            var defaultRightIcons = new IconList {
                new Icons.Active(), new Icons.Lock(), new Icons.Static(), new Icons.PrefabApply()
            };
            var defaultLayerColors = new List <LayerColor> {
                new LayerColor(5, new Color(0f, 0f, 1f, 0.3019608f))
            };

            LeftIcons.DefaultValue         = defaultLeftIcons;
            RightIcons.DefaultValue        = defaultRightIcons;
            PerLayerRowColors.DefaultValue = defaultLayerColors;

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

            leftIconsList.onAddDropdownCallback  = (rect, newList) => LeftIconsMenu.DropDown(rect);
            rightIconsList.onAddDropdownCallback = (rect, newList) => RightIconsMenu.DropDown(rect);

            rowColorsList = GenerateReordableList(PerLayerRowColors);
            rowColorsList.onAddDropdownCallback = (rect, newList) => RowColorsMenu.DropDown(rect);

            rowColorsList.drawElementCallback = (rect, index, focused, active) => {
                GUI.changed = false;

                rect.xMin -= EditorGUI.indentLevel * 16f;
                PerLayerRowColors.Value[index] = LayerColorField(rect, PerLayerRowColors.Value[index]);

                if (GUI.changed)
                {
                    PerLayerRowColors.ForceSave();
                }
            };
        }
Exemplo n.º 2
0
        static Preferences()
        {
            InitializePreferences();

            Enabled.Label.text = string.Format("Enabled ({0}+H)", Utility.CtrlKey);

            #if UNITY_2018_3_OR_NEWER
            LeftSideButtonPref.DefaultValue = new IconData()
            {
                Icon = new Icons.None()
            };
            #else
            LeftSideButtonPref.DefaultValue = new IconData()
            {
                Icon = new Icons.GameObjectIcon()
            };
            #endif

            LineColor.DefaultValue      = DefaultLineColor;
            OddRowColor.DefaultValue    = DefaultOddSortColor;
            EvenRowColor.DefaultValue   = DefaultEvenSortColor;
            HoverTintColor.DefaultValue = DefaultHoverTint;

            var defaultLeftIcons = new IconList {
                new Icons.MonoBehaviourIcon(), new Icons.Warnings(), new Icons.SoundIcon()
            };
            var defaultRightIcons = new IconList {
                new Icons.Active(), new Icons.Lock(), new Icons.Static(), new Icons.PrefabApply()
            };
            var defaultLayerColors = new List <LayerColor> {
                new LayerColor(5, new Color(0f, 0f, 1f, 0.3019608f))
            };

            LeftIcons.DefaultValue         = defaultLeftIcons;
            RightIcons.DefaultValue        = defaultRightIcons;
            PerLayerRowColors.DefaultValue = defaultLayerColors;
            MiniLabels.DefaultValue        = new [] {
                Array.IndexOf(MiniLabelProvider.MiniLabelsTypes, typeof(LayerMiniLabel)),
                Array.IndexOf(MiniLabelProvider.MiniLabelsTypes, typeof(TagMiniLabel))
            };

            minilabelsNames = MiniLabelProvider.MiniLabelsTypes
                              .Select(ml => ml == null? "None": ObjectNames.NicifyVariableName(ml.Name.Replace("MiniLabel", "")))
                              .ToArray();

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

            leftIconsList.onAddDropdownCallback  = (rect, newList) => LeftIconsMenu.DropDown(rect);
            rightIconsList.onAddDropdownCallback = (rect, newList) => RightIconsMenu.DropDown(rect);

            rowColorsList = GenerateReordableList(PerLayerRowColors);
            rowColorsList.onAddDropdownCallback = (rect, newList) => RowColorsMenu.DropDown(rect);

            rowColorsList.drawElementCallback = (rect, index, focused, active) => {
                GUI.changed = false;

                rect.xMin -= EditorGUI.indentLevel * 16f;
                PerLayerRowColors.Value[index] = LayerColorField(rect, PerLayerRowColors.Value[index]);

                if (GUI.changed)
                {
                    PerLayerRowColors.ForceSave();
                }
            };

            rowColorsNamedList = GenerateReordableList(PerNameRowColors);
            rowColorsNamedList.onAddDropdownCallback = (rect, newList) => RowNameColorsMenu.DropDown(rect);

            rowColorsNamedList.drawElementCallback = (rect, index, focused, active) => {
                GUI.changed = false;

                rect.xMin -= EditorGUI.indentLevel * 16f;
                PerNameRowColors.Value[index] = NameColorField(rect, PerNameRowColors.Value[index]);

                if (GUI.changed)
                {
                    PerNameRowColors.ForceSave();
                }
            };

            RecreateMiniLabelProviders();
        }