Exemple #1
0
        public void GUIMinMaxGradient(GUIContent label, SerializedMinMaxGradient minMaxGradient)
        {
            MinMaxGradientState state = minMaxGradient.state;
            bool flag      = state >= MinMaxGradientState.k_RandomBetweenTwoColors;
            Rect rect      = GUILayoutUtility.GetRect(0f, (float)((!flag) ? 13 : 26));
            Rect popupRect = ModuleUI.GetPopupRect(rect);

            rect = ModuleUI.SubtractPopupWidth(rect);
            Rect rect2 = ModuleUI.PrefixLabel(rect, label);

            rect2.height = 13f;
            switch (state)
            {
            case MinMaxGradientState.k_Color:
                ModuleUI.GUIColor(rect2, minMaxGradient.m_MaxColor);
                break;

            case MinMaxGradientState.k_Gradient:
                EditorGUI.GradientField(rect2, minMaxGradient.m_MaxGradient);
                break;

            case MinMaxGradientState.k_RandomBetweenTwoColors:
                ModuleUI.GUIColor(rect2, minMaxGradient.m_MaxColor);
                rect2.y += rect2.height;
                ModuleUI.GUIColor(rect2, minMaxGradient.m_MinColor);
                break;

            case MinMaxGradientState.k_RandomBetweenTwoGradients:
                EditorGUI.GradientField(rect2, minMaxGradient.m_MaxGradient);
                rect2.y += rect2.height;
                EditorGUI.GradientField(rect2, minMaxGradient.m_MinGradient);
                break;
            }
            ModuleUI.GUIMMGradientPopUp(popupRect, minMaxGradient);
        }
 private void SetMinMaxState(MinMaxGradientState newState)
 {
     if (newState != this.state)
     {
         this.m_MinMaxState.intValue = (int)newState;
     }
 }
 private void SetMinMaxState(MinMaxGradientState newState)
 {
     if (newState != this.state)
     {
         this.m_MinMaxState.intValue = (int) newState;
     }
 }
Exemple #4
0
        public static void GUIMMGradientPopUp(Rect rect, SerializedMinMaxGradient gradientProp)
        {
            if (!EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown))
            {
                return;
            }
            GUIContent[] guiContentArray = new GUIContent[4] {
                new GUIContent("Color"), new GUIContent("Gradient"), new GUIContent("Random Between Two Colors"), new GUIContent("Random Between Two Gradients")
            };
            MinMaxGradientState[] maxGradientStateArray = new MinMaxGradientState[4] {
                MinMaxGradientState.k_Color, MinMaxGradientState.k_Gradient, MinMaxGradientState.k_RandomBetweenTwoColors, MinMaxGradientState.k_RandomBetweenTwoGradients
            };
            bool[] flagArray = new bool[4] {
                (gradientProp.m_AllowColor ? 1 : 0) != 0, (gradientProp.m_AllowGradient ? 1 : 0) != 0, (gradientProp.m_AllowRandomBetweenTwoColors ? 1 : 0) != 0, (gradientProp.m_AllowRandomBetweenTwoGradients ? 1 : 0) != 0
            };
            GenericMenu genericMenu = new GenericMenu();

            for (int index = 0; index < guiContentArray.Length; ++index)
            {
                if (flagArray[index])
                {
                    genericMenu.AddItem(guiContentArray[index], gradientProp.state == maxGradientStateArray[index], new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxGradientStateCallback), (object)new ModuleUI.GradientCallbackData(maxGradientStateArray[index], gradientProp));
                }
            }
            genericMenu.ShowAsContext();
            Event.current.Use();
        }
Exemple #5
0
        public void GUIMinMaxGradient(GUIContent label, SerializedMinMaxGradient minMaxGradient)
        {
            MinMaxGradientState state = minMaxGradient.state;
            bool flag      = state >= MinMaxGradientState.k_RandomBetweenTwoColors;
            Rect position  = GUILayoutUtility.GetRect(0f, !flag ? ((float)13) : ((float)0x1a));
            Rect popupRect = GetPopupRect(position);
            Rect rect      = PrefixLabel(SubtractPopupWidth(position), label);

            rect.height = 13f;
            switch (state)
            {
            case MinMaxGradientState.k_Color:
                GUIColor(rect, minMaxGradient.m_MaxColor);
                break;

            case MinMaxGradientState.k_Gradient:
                EditorGUI.GradientField(rect, minMaxGradient.m_MaxGradient);
                break;

            case MinMaxGradientState.k_RandomBetweenTwoColors:
                GUIColor(rect, minMaxGradient.m_MaxColor);
                rect.y += rect.height;
                GUIColor(rect, minMaxGradient.m_MinColor);
                break;

            case MinMaxGradientState.k_RandomBetweenTwoGradients:
                EditorGUI.GradientField(rect, minMaxGradient.m_MaxGradient);
                rect.y += rect.height;
                EditorGUI.GradientField(rect, minMaxGradient.m_MinGradient);
                break;
            }
            GUIMMGradientPopUp(popupRect, minMaxGradient);
        }
        private void SetMinMaxState(MinMaxGradientState newState)
        {
            if (newState == state)
            {
                return;
            }

            m_MinMaxState.intValue = (int)newState;
        }
Exemple #7
0
 public static void GUIMMGradientPopUp(Rect rect, SerializedMinMaxGradient gradientProp)
 {
     if (EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown))
     {
         GUIContent[] array = new GUIContent[]
         {
             new GUIContent("Color"),
             new GUIContent("Gradient"),
             new GUIContent("Random Between Two Colors"),
             new GUIContent("Random Between Two Gradients"),
             new GUIContent("Random Color")
         };
         MinMaxGradientState[] array2 = new MinMaxGradientState[]
         {
             MinMaxGradientState.k_Color,
             MinMaxGradientState.k_Gradient,
             MinMaxGradientState.k_RandomBetweenTwoColors,
             MinMaxGradientState.k_RandomBetweenTwoGradients,
             MinMaxGradientState.k_RandomColor
         };
         bool[] array3 = new bool[]
         {
             gradientProp.m_AllowColor,
             gradientProp.m_AllowGradient,
             gradientProp.m_AllowRandomBetweenTwoColors,
             gradientProp.m_AllowRandomBetweenTwoGradients,
             gradientProp.m_AllowRandomColor
         };
         GenericMenu genericMenu = new GenericMenu();
         for (int i = 0; i < array.Length; i++)
         {
             if (array3[i])
             {
                 GenericMenu arg_FB_0 = genericMenu;
                 GUIContent  arg_FB_1 = array[i];
                 bool        arg_FB_2 = gradientProp.state == array2[i];
                 if (ModuleUI.< > f__mg$cache1 == null)
                 {
                     ModuleUI.< > f__mg$cache1 = new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxGradientStateCallback);
                 }
                 arg_FB_0.AddItem(arg_FB_1, arg_FB_2, ModuleUI.< > f__mg$cache1, new ModuleUI.GradientCallbackData(array2[i], gradientProp));
             }
         }
         genericMenu.ShowAsContext();
         Event.current.Use();
     }
 }
Exemple #8
0
 public static void GUIMMGradientPopUp(Rect rect, SerializedMinMaxGradient gradientProp)
 {
     if (EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown))
     {
         GUIContent[]          contentArray = new GUIContent[] { new GUIContent("Color"), new GUIContent("Gradient"), new GUIContent("Random Between Two Colors"), new GUIContent("Random Between Two Gradients") };
         MinMaxGradientState[] stateArray1  = new MinMaxGradientState[4];
         stateArray1[1] = MinMaxGradientState.k_Gradient;
         stateArray1[2] = MinMaxGradientState.k_RandomBetweenTwoColors;
         stateArray1[3] = MinMaxGradientState.k_RandomBetweenTwoGradients;
         MinMaxGradientState[] stateArray = stateArray1;
         bool[]      flagArray            = new bool[] { gradientProp.m_AllowColor, gradientProp.m_AllowGradient, gradientProp.m_AllowRandomBetweenTwoColors, gradientProp.m_AllowRandomBetweenTwoGradients };
         GenericMenu menu = new GenericMenu();
         for (int i = 0; i < contentArray.Length; i++)
         {
             if (flagArray[i])
             {
                 menu.AddItem(contentArray[i], gradientProp.state == stateArray[i], new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxGradientStateCallback), new GradientCallbackData(stateArray[i], gradientProp));
             }
         }
         menu.ShowAsContext();
         Event.current.Use();
     }
 }
 public GradientCallbackData(MinMaxGradientState state, SerializedMinMaxGradient p)
 {
   this.gradientProp = p;
   this.selectedState = state;
 }
 public static void GUIMMGradientPopUp(Rect rect, SerializedMinMaxGradient gradientProp)
 {
   if (!EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown))
     return;
   GUIContent[] guiContentArray = new GUIContent[4]{ new GUIContent("Color"), new GUIContent("Gradient"), new GUIContent("Random Between Two Colors"), new GUIContent("Random Between Two Gradients") };
   MinMaxGradientState[] maxGradientStateArray = new MinMaxGradientState[4]{ MinMaxGradientState.k_Color, MinMaxGradientState.k_Gradient, MinMaxGradientState.k_RandomBetweenTwoColors, MinMaxGradientState.k_RandomBetweenTwoGradients };
   bool[] flagArray = new bool[4]{ (gradientProp.m_AllowColor ? 1 : 0) != 0, (gradientProp.m_AllowGradient ? 1 : 0) != 0, (gradientProp.m_AllowRandomBetweenTwoColors ? 1 : 0) != 0, (gradientProp.m_AllowRandomBetweenTwoGradients ? 1 : 0) != 0 };
   GenericMenu genericMenu = new GenericMenu();
   for (int index = 0; index < guiContentArray.Length; ++index)
   {
     if (flagArray[index])
       genericMenu.AddItem(guiContentArray[index], gradientProp.state == maxGradientStateArray[index], new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxGradientStateCallback), (object) new ModuleUI.GradientCallbackData(maxGradientStateArray[index], gradientProp));
   }
   genericMenu.ShowAsContext();
   Event.current.Use();
 }
Exemple #11
0
 public GradientCallbackData(MinMaxGradientState state, SerializedMinMaxGradient p)
 {
     this.gradientProp  = p;
     this.selectedState = state;
 }
Exemple #12
0
 public static void GUIMMGradientPopUp(Rect rect, SerializedMinMaxGradient gradientProp)
 {
     if (EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown))
     {
         GUIContent[] contentArray = new GUIContent[] { new GUIContent("Color"), new GUIContent("Gradient"), new GUIContent("Random Between Two Colors"), new GUIContent("Random Between Two Gradients") };
         MinMaxGradientState[] stateArray1 = new MinMaxGradientState[4];
         stateArray1[1] = MinMaxGradientState.k_Gradient;
         stateArray1[2] = MinMaxGradientState.k_RandomBetweenTwoColors;
         stateArray1[3] = MinMaxGradientState.k_RandomBetweenTwoGradients;
         MinMaxGradientState[] stateArray = stateArray1;
         bool[] flagArray = new bool[] { gradientProp.m_AllowColor, gradientProp.m_AllowGradient, gradientProp.m_AllowRandomBetweenTwoColors, gradientProp.m_AllowRandomBetweenTwoGradients };
         GenericMenu menu = new GenericMenu();
         for (int i = 0; i < contentArray.Length; i++)
         {
             if (flagArray[i])
             {
                 menu.AddItem(contentArray[i], gradientProp.state == stateArray[i], new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxGradientStateCallback), new GradientCallbackData(stateArray[i], gradientProp));
             }
         }
         menu.ShowAsContext();
         Event.current.Use();
     }
 }
        static void SetupMinMaxGradient(SerializedProperty property, GenericMenu menu, Event evt)
        {
            var canCopy       = !property.hasMultipleDifferentValues;
            var canPasteWhole = GUI.enabled && Clipboard.HasSerializedProperty();

            if (menu != null)
            {
                AddSeparator(menu);

                var copyContent = overrideCopyContent ?? kCopyContent;
                if (canCopy)
                {
                    menu.AddItem(copyContent, false, o => Clipboard.SetSerializedProperty((SerializedProperty)o), property);
                }
                else
                {
                    menu.AddDisabledItem(copyContent);
                }

                var pasteContent = overridePasteContent ?? kPasteContent;

                if (canPasteWhole)
                {
                    menu.AddItem(pasteContent, false,
                                 delegate(object o)
                    {
                        var prop = (SerializedProperty)o;
                        Clipboard.GetSerializedProperty(prop);
                        prop.serializedObject.ApplyModifiedProperties();
                    }, property);
                }
                else if (GUI.enabled && Clipboard.hasColor)
                {
                    MinMaxGradientState state = (MinMaxGradientState)property.FindPropertyRelative("minMaxState").intValue;
                    if (state == MinMaxGradientState.k_Color)
                    {
                        AddPasteColorItem(property.FindPropertyRelative("maxColor"), menu, pasteContent);
                    }
                    else if (state == MinMaxGradientState.k_RandomBetweenTwoColors)
                    {
                        // Allow the user to choose whether to paste the color on their clipboard to either the max or min
                        AddPasteColorItem(property.FindPropertyRelative("maxColor"), menu, kPasteMaxColorContent);
                        AddPasteColorItem(property.FindPropertyRelative("minColor"), menu, kPasteMinColorContent);
                    }
                    else
                    {
                        menu.AddDisabledItem(pasteContent);
                    }
                }
                else if (GUI.enabled && Clipboard.hasGradient)
                {
                    MinMaxGradientState state = (MinMaxGradientState)property.FindPropertyRelative("minMaxState").intValue;
                    if (state == MinMaxGradientState.k_Gradient || state == MinMaxGradientState.k_RandomColor)
                    {
                        AddPasteGradientItem(property.FindPropertyRelative("maxGradient"), menu, pasteContent);
                    }
                    else if (state == MinMaxGradientState.k_RandomBetweenTwoGradients)
                    {
                        // Allow the user to choose whether to paste the gradient on their clipboard to either the max or min
                        AddPasteGradientItem(property.FindPropertyRelative("maxGradient"), menu, kPasteMaxGradientContent);
                        AddPasteGradientItem(property.FindPropertyRelative("minGradient"), menu, kPasteMinGradientContent);
                    }
                    else
                    {
                        menu.AddDisabledItem(pasteContent);
                    }
                }
                else
                {
                    menu.AddDisabledItem(pasteContent);
                }
            }
            if (evt != null)
            {
                if (canCopy && evt.commandName == EventCommandNames.Copy)
                {
                    if (evt.type == EventType.ValidateCommand)
                    {
                        evt.Use();
                    }
                    if (evt.type == EventType.ExecuteCommand)
                    {
                        Clipboard.SetSerializedProperty(property);
                        evt.Use();
                    }
                }
                if (canPasteWhole && evt.commandName == EventCommandNames.Paste)
                {
                    if (evt.type == EventType.ValidateCommand)
                    {
                        evt.Use();
                    }
                    if (evt.type == EventType.ExecuteCommand)
                    {
                        Clipboard.GetSerializedProperty(property);
                        property.serializedObject.ApplyModifiedProperties();
                        evt.Use();
                    }
                }
            }
        }