Esempio n. 1
0
        /// <summary>
        /// Draws the GUI for the color property.
        /// </summary>
        /// <param name="position">Rectangle on the screen to use for the property GUI.</param>
        /// <param name="property">The SerializedProperty to make the custom GUI for.</param>
        /// <param name="label">The label of this property.</param>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            var h   = property.FindPropertyRelative("h");
            var c   = property.FindPropertyRelative("c");
            var v   = property.FindPropertyRelative("v");
            var a   = property.FindPropertyRelative("a");
            var hcy = new ColorHCV(h.floatValue, c.floatValue, v.floatValue, a.floatValue);

            hcy          = EditorGUI.ColorField(position, hcy);
            h.floatValue = hcy.h;
            c.floatValue = hcy.c;
            v.floatValue = hcy.v;
            a.floatValue = hcy.a;
            EditorGUI.EndProperty();
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a color by converting the given HCV color to the CMY color space.
 /// </summary>
 /// <param name="hcv">The HCV color to convert to CMY.</param>
 public ColorCMY(ColorHCV hcv)
 {
     this = FromHCV(hcv.h, hcv.c, hcv.v, hcv.a);
 }