Color Struct

Representation of RGBA colors.

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.

Components (r,g,b) define a color in RGB color space. Alpha component (a) defines transparency - alpha of one is completely opaque, alpha of zero is completely transparent.

Variables
r

Red component of the color.

g

Green component of the color.

b

Blue component of the color.

a

Alpha component of the color.

grayscale

The grayscale value of the color. (Read Only)

this [int index]

Access the r, g, b,a components using [0], [1], [2], [3] respectively.

Constructors
Color

Constructs a new Color with given r,g,b,a components.

Functions
ToString

Returns a nicely formatted string of this color.

Class Variables
red

Solid red. RGBA is (1, 0, 0, 1).

green

Solid green. RGBA is (0, 1, 0, 1).

blue

Solid blue. RGBA is (0, 0, 1, 1).

white

Solid white. RGBA is (1, 1, 1, 1).

black

Solid black. RGBA is (0, 0, 0, 1).

yellow

Yellow. RGBA is (1, 0.92, 0.016, 1), but the color is nice to look at!

cyan

Cyan. RGBA is (0, 1, 1, 1).

magenta

Magenta. RGBA is (1, 0, 1, 1).

gray

Gray. RGBA is (0.5, 0.5, 0.5, 1).

grey

English spelling for gray. RGBA is the same (0.5, 0.5, 0.5, 1).

clear

Completely transparent. RGBA is (0, 0, 0, 0).

Class Functions
operator +

Adds two colors together. Each component is added separately.

operator -

Subtracts color b from color a. Each component is subtracted separately.

operator *

Multiplies two colors together. Each component is multiplied separately.

operator /

Divides color a by the float b. Each color component is scaled separately.

Lerp

Interpolates between colors a and b by t.

operator Vector4

A version of the color that has had the inverse gamma curve applied.

operator Color

Colors can be implicitly converted to and from Vector4.