14 [AttributeUsage(AttributeTargets.Field)]
34 this.startColor = GetColor(startColor);
35 this.endColor = GetColor(endColor);
36 this.startColor.a = startAlpha;
37 this.endColor.a = endAlpha;
41 public override void DrawEditor(
UnityEngine.Object target, FieldInfo field, SerializedProperty property)
43 Gradient gradientValue = field.GetValue(target) as Gradient;
45 if (gradientValue == null || gradientValue.colorKeys == null || gradientValue.colorKeys.Length == 0)
46 gradientValue = GetDefault();
48 EditorGUILayout.BeginHorizontal();
49 EditorGUILayout.PropertyField(property);
50 if (GUILayout.Button(
"Default"))
52 gradientValue = GetDefault();
54 EditorGUILayout.EndHorizontal();
56 field.SetValue(target, gradientValue);
59 public override void DrawEditor(
UnityEngine.Object target, PropertyInfo prop)
61 throw new NotImplementedException();
65 private Gradient GetDefault()
67 Gradient gradient =
new Gradient();
68 GradientColorKey[] colorKeys =
new GradientColorKey[2] {
69 new GradientColorKey(startColor, 0f),
70 new GradientColorKey(endColor, 1f)
72 GradientAlphaKey[] alphaKeys =
new GradientAlphaKey[2]
74 new GradientAlphaKey(startColor.a, 0f),
75 new GradientAlphaKey(endColor.a, 0f),
77 gradient.SetKeys(colorKeys, alphaKeys);
81 private Color startColor;
82 private Color endColor;
84 private static Color GetColor(
ColorEnum color)
102 return Color.magenta;