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 y   = property.FindPropertyRelative("y");
            var a   = property.FindPropertyRelative("a");
            var hcy = new ColorHCY(h.floatValue, c.floatValue, y.floatValue, a.floatValue);

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