Пример #1
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                HierarchyUtil.LabelField("Text");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo("Show Tag name");

                    this.enabledText = HierarchyUtil.Toggle("Enabeld", this.enabledText,
                                                            @"Display text on the side");

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.textColorUntagged = HierarchyUtil.ColorField("Untagged Color", this.textColorUntagged,
                                                                          @"Color for layer, Untagged");
                        HierarchyUtil.Button("Reset", ResetTextUntaggedColor);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.textColor = HierarchyUtil.ColorField("Color", this.textColor,
                                                                  @"Text color for other meaningful tags");
                        HierarchyUtil.Button("Reset", ResetTextColor);
                    });
                });

                HierarchyUtil.LabelField("Item");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo("Colorized Item");

                    this.enabledItem = HierarchyUtil.Toggle("Enabeld", this.enabledItem,
                                                            @"Colorized items in hierarchy");

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        HierarchyUtil.LabelField("Colors", @"Color mapping for each tag");
                        HierarchyUtil.Button("Add", AddTagColor);
                    });

                    HierarchyUtil.CreateGroup(() =>
                    {
                        string[] tags = InternalEditorUtility.tags;

                        int drawn = 0;

                        for (int count = 0; count < itemColors.Count; ++count)
                        {
                            string oldName   = itemColors.Keys.ElementAt(count);
                            int oldSelection = TagToIndex(oldName);

                            HierarchyUtil.BeginHorizontal(() =>
                            {
                                int currentSelection = HierarchyUtil.Popup(oldSelection, tags);
                                string currentName   = IndexToTag(currentSelection);

                                Color col = HierarchyUtil.ColorField("", itemColors[oldName],
                                                                     @"Color for this tag, " + currentName);

                                RemoveTagColor(oldName);
                                if (itemColors.ContainsKey(currentName))
                                {
                                    itemColors[currentName] = col;
                                }
                                else
                                {
                                    itemColors.Add(currentName, col);
                                }

                                if (HierarchyUtil.Button("Remove"))
                                {
                                    RemoveTagColor(currentName);
                                }

                                ++drawn;
                            });
                        }

                        if (drawn == 0)
                        {
                            EditorGUILayout.LabelField("No specification");
                        }
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.gradientLength = HierarchyUtil.Slider("Gradient Length", this.gradientLength, 0.01f, 1.0f,
                                                                   @"Time of the gradient faded to alpha 0");
                        HierarchyUtil.Button("Reset", ResetGradientLength);
                    });

                    this.invertDirection = HierarchyUtil.Toggle("Invert", this.invertDirection,
                                                                @"Invert the gradient direction");
                });
            });
        }