public static void ShowPopup(Color baseColor, System.Action <Color> selectedColorCallback)
        {
            if (instance == null)
            {
                instance = ScriptableObject.CreateInstance <ColorHelperPopupWindow>();
                instance.wantsMouseMove = true;
            }
            instance.selectedColor         = baseColor;
            instance.baseSchemeColor       = baseColor;
            instance.selectedColorCallback = selectedColorCallback;
            Vector2 realPosition = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            instance.position = new Rect(realPosition.x, realPosition.y, 310, 181);
            instance.ShowPopup();
            instance.Focus();
        }
Пример #2
0
        private void SetupColorGroupRList(ColorGroup cg)
        {
            if (cg == null)
            {
                return;
            }

            colorsList = new ReorderableList(cg.colorList, typeof(NamedColor), true, true, true, true);

            colorsList.drawHeaderCallback = (Rect rect) =>
            {
                GUI.Label(rect, "Colors");
            };

            colorsList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                rect.width *= 0.5f;
                NamedColor nc   = cg[index];
                string     name = EditorGUI.TextField(rect, nc.Name);
                if (name != nc.Name)
                {
                    nc.Name = name;
                }
                rect.x     += rect.width + 5;
                rect.width -= 35f;
                nc.color    = EditorGUI.ColorField(rect, nc.color);
                rect.x     += rect.width + 5;
                rect.y     -= 2;
                rect.width  = 30f;
                if (GUI.Button(rect, StylesUI.PaletteButton, StylesUI.IconPalette))
                {
                    ColorHelperPopupWindow.ShowPopup(nc.color, (c) => { nc.color = c; this.Repaint(); });
                }
            };
            colorsList.elementHeight = 16f;
            colorsList.onAddCallback = (ReorderableList r) =>
            {
                if (cg.Count > 0)
                {
                    cg.Add(new NamedColor(cg[cg.Count - 1]));
                }
                else
                {
                    cg.Add(new NamedColor("New", Color.white));
                }
            };
        }