Ejemplo n.º 1
0
        public bool OnCollectionButton(Rect rect, bool isSelected)
        {
            var iconRect = new Rect(rect)
            {
                width = 18, height = 18
            };

            iconRect.y -= 1;

            var guiColor  = GUI.color;
            var tintColor = ColorTags.GetColor(collection.colorTag);

            var icon = instance.transform.childCount == 0 ? folderEmptyIcon : folderIcon;

            if (!instance.activeInHierarchy)
            {
                GUI.color *= new Color(1, 1, 1, 0.5f);
            }

            GUI.color *= tintColor;

            if (GUI.Button(iconRect, collectionsIcon, EditorStyles.label))
            {
                return(true);
            }

            GUI.color = guiColor;
            return(false);
        }
        public static void DrawIcon(this ViewItem item, Rect rect, bool isOn)
        {
            var isCollection = item.isCollection;

            var iconRect = new Rect(rect)
            {
                width = 16, height = 16
            };

            iconRect.y += (rect.height - 16) / 2;

            var color = GUI.color;

            if (isCollection && !isOn)
            {
                color *= ColorTags.GetColor(item.collection.colorTag);
            }

            var renderDisabled = item.colorCode >= 4;

            if (renderDisabled)
            {
                color *= new Color(1f, 1f, 1f, 0.5f);
            }

            if (item.effectiveIcon)
            {
                DrawIcon(iconRect, item.effectiveIcon, color, isOn);
            }

            if (item.overlayIcon)
            {
                DrawIcon(iconRect, item.overlayIcon, color);
            }
        }
Ejemplo n.º 3
0
        public CollectionPopup(Collection collection)
        {
            title = $"Collection";

            serializedObject = new SerializedObject(collection);
            colorTagProperty = serializedObject.FindProperty("colorTag");

            var colorTags = Enum.GetValues(typeof(ColorTag)) as ColorTag[];

            var tagsBar = new Toolbar();

            foreach (var tag in colorTags)
            {
                var color = ColorTags.GetColor(tag);
                var image = new VisualElement
                {
                    style =
                    {
                        backgroundImage               = collectionsIcon,
                        unityBackgroundImageTintColor = color,
                        width                         =              16,height= 16
                    }
                };
                var button = new Button {
                    style = { unityBackgroundImageTintColor = color }, userData = tag
                };

                button.AddToClassList("highlight-button");
                button.Add(image);

                button.clicked += () => OnTagClick(button);

                tagsBar.Add(button);
            }

            contentContainer.Add(tagsBar);
        }