Skip to main content

Color

Representation of RGBA colors.

Members

Properties

NameDescription
Color.aAlpha component of the color (0 is transparent, 1 is opaque).
Color.bBlue component of the color.
Color.gGreen component of the color.
Color.gammaA version of the color that has had the gamma curve applied.
Color.grayscaleThe grayscale value of the color. (Read Only)
Color.linearA linear value of an sRGB color.
Color.maxColorComponentReturns the maximum color component value: Max(r,g,b).
Color.rRed component of the color.

Static Properties

NameDescription
Color.blackSolid black. RGBA is (0, 0, 0, 1).
Color.blueSolid blue. RGBA is (0, 0, 1, 1).
Color.clearCompletely transparent. RGBA is (0, 0, 0, 0).
Color.cyanCyan. RGBA is (0, 1, 1, 1).
Color.grayGray. RGBA is (0.5, 0.5, 0.5, 1).
Color.greenSolid green. RGBA is (0, 1, 0, 1).
Color.magentaMagenta. RGBA is (1, 0, 1, 1).
Color.redSolid red. RGBA is (1, 0, 0, 1).
Color.whiteSolid white. RGBA is (1, 1, 1, 1).
Color.yellowYellow. RGBA is (1, 0.92, 0.016, 1), but the color is nice to look at!

Constructor

NameDescription
[Color(r, g, b, a=1.0)](./Color Constructor.md)Constructs a new Color with given r,g,b,a components.

Static Methods

NameDescription
Color.HSVToRGB(H, S, V)Creates an RGB colour from HSV input.
Color.HSVToRGB(H, S, V, hdr)Creates an RGB color from the hue, saturation and value of the input.
Color.Lerp(a, b, t)Linearly interpolates between colors a and b by t.
Color.LerpUnclamped(a, b, t )Linearly interpolates between colors a and b by t.
Color.RGBToHSV(rgbColor)Calculates the hue, saturation and value of an RGB input color.

Operators

NameDescription
Operator (Color-Color)Subtracts color lhs from color rhs. Each component is subtracted separately.

| Operator (Color*Color) | Multiplies two colors together. Each component is multiplied separately. |

| Operator (Color*number) | Multiplies color lhs by the number rhs. Each color component is scaled separately. |

| Operator (number*Color) | Multiplies color rhs by the number lhs. Each color component is scaled separately. |

| Operator (Color/number) | Divides color lhs by the number rhs. Each color component is scaled separately. |

| Operator (Color+Color) | Adds two colors together. Each component is added separately. |

| Implicit Cast Operator (Vector4) | Colors can be implicitly converted to and from Vector4. |

Extra Detail

This structure is used throughout Unity to pass colors around. Each color component is a floating point value with a range from 0 to 1.