internal static void Show(SerializedProperty prop)
 {
     GUIContent content = new GUIContent("Copy");
     GUIContent content2 = new GUIContent("Paste");
     GenericMenu menu = new GenericMenu();
     GradientContextMenu menu2 = new GradientContextMenu(prop);
     menu.AddItem(content, false, new GenericMenu.MenuFunction(menu2.Copy));
     if (ParticleSystemClipboard.HasSingleGradient())
     {
         menu.AddItem(content2, false, new GenericMenu.MenuFunction(menu2.Paste));
     }
     else
     {
         menu.AddDisabledItem(content2);
     }
     menu.ShowAsContext();
 }
        internal static void Show(SerializedProperty prop)
        {
            GUIContent          content     = EditorGUIUtility.TrTextContent("Copy", null, null);
            GUIContent          content2    = EditorGUIUtility.TrTextContent("Paste", null, null);
            GenericMenu         genericMenu = new GenericMenu();
            GradientContextMenu @object     = new GradientContextMenu(prop);

            genericMenu.AddItem(content, false, new GenericMenu.MenuFunction(@object.Copy));
            if (ParticleSystemClipboard.HasSingleGradient())
            {
                genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(@object.Paste));
            }
            else
            {
                genericMenu.AddDisabledItem(content2);
            }
            genericMenu.ShowAsContext();
        }
        internal static void Show(SerializedProperty prop)
        {
            GUIContent          content  = new GUIContent("Copy");
            GUIContent          content2 = new GUIContent("Paste");
            GenericMenu         menu     = new GenericMenu();
            GradientContextMenu menu2    = new GradientContextMenu(prop);

            menu.AddItem(content, false, new GenericMenu.MenuFunction(menu2.Copy));
            if (ParticleSystemClipboard.HasSingleGradient())
            {
                menu.AddItem(content2, false, new GenericMenu.MenuFunction(menu2.Paste));
            }
            else
            {
                menu.AddDisabledItem(content2);
            }
            menu.ShowAsContext();
        }
示例#4
0
        internal static void Show(SerializedProperty prop)
        {
            GUIContent copy  = EditorGUIUtility.TrTextContent("Copy");
            GUIContent paste = EditorGUIUtility.TrTextContent("Paste");

            GenericMenu menu         = new GenericMenu();
            var         gradientMenu = new GradientContextMenu(prop);

            menu.AddItem(copy, false, gradientMenu.Copy);
            if (Clipboard.hasGradient)
            {
                menu.AddItem(paste, false, gradientMenu.Paste);
            }
            else
            {
                menu.AddDisabledItem(paste);
            }
            menu.ShowAsContext();
            Event.current.Use();
        }
        static internal void Show(SerializedProperty prop)
        {
            // Curve context menu
            GUIContent copy  = EditorGUIUtility.TrTextContent("Copy");
            GUIContent paste = EditorGUIUtility.TrTextContent("Paste");

            GenericMenu menu         = new GenericMenu();
            var         gradientMenu = new GradientContextMenu(prop);

            menu.AddItem(copy, false, gradientMenu.Copy);
            if (ParticleSystemClipboard.HasSingleGradient())
            {
                menu.AddItem(paste, false, gradientMenu.Paste);
            }
            else
            {
                menu.AddDisabledItem(paste);
            }

            menu.ShowAsContext();
        }
        internal static Gradient DoGradientField(Rect position, int id, Gradient value, SerializedProperty property, bool hdr)
        {
            Event evt = Event.current;

            switch (evt.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (position.Contains(evt.mousePosition))
                {
                    if (evt.button == 0)
                    {
                        s_GradientID = id;
                        GUIUtility.keyboardControl = id;
                        Gradient gradient = property != null ? property.gradientValue : value;
                        GradientPicker.Show(gradient, hdr);
                        GUIUtility.ExitGUI();
                    }
                    else if (evt.button == 1)
                    {
                        if (property != null)
                        {
                            GradientContextMenu.Show(property.Copy());
                        }
                        // TODO: make work for Gradient value
                    }
                }
                break;

            case EventType.Repaint:
            {
                Rect r2 = new Rect(position.x + 1, position.y + 1, position.width - 2, position.height - 2);        // Adjust for box drawn on top
                if (property != null)
                {
                    GradientEditor.DrawGradientSwatch(r2, property, Color.white);
                }
                else
                {
                    GradientEditor.DrawGradientSwatch(r2, value, Color.white);
                }
                EditorStyles.colorPickerBox.Draw(position, GUIContent.none, id);
                break;
            }

            case EventType.ExecuteCommand:
                if (s_GradientID == id && evt.commandName == GradientPicker.GradientPickerChangedCommand)
                {
                    GUI.changed = true;
                    GradientPreviewCache.ClearCache();
                    HandleUtility.Repaint();
                    if (property != null)
                    {
                        property.gradientValue = GradientPicker.gradient;
                    }

                    return(GradientPicker.gradient);
                }
                break;

            case EventType.ValidateCommand:
                if (s_GradientID == id && evt.commandName == EventCommandNames.UndoRedoPerformed)
                {
                    if (property != null)
                    {
                        GradientPicker.SetCurrentGradient(property.gradientValue);
                    }
                    GradientPreviewCache.ClearCache();
                    return(value);
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.keyboardControl == id && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter))
                {
                    Event.current.Use();
                    Gradient gradient = property != null ? property.gradientValue : value;
                    GradientPicker.Show(gradient, hdr);
                    GUIUtility.ExitGUI();
                }
                break;
            }
            return(value);
        }