Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Color

struct in UnityEngine

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

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.

Static Variables

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

Variables

aAlpha component of the color.
bBlue component of the color.
gGreen component of the color.
gammaA version of the color that has had the gamma curve applied.
grayscaleThe grayscale value of the color. (Read Only)
linearA version of the color that has had the inverse gamma curve applied.
maxColorComponentReturns the maximum color component value: Max(r,g,b).
rRed component of the color.
this[int]Access the r, g, b,a components using [0], [1], [2], [3] respectively.

Constructors

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

Public Functions

ToStringReturns a nicely formatted string of this color.

Static Functions

LerpLinearly interpolates between colors a and b by t.
LerpUnclampedLinearly interpolates between colors a and b by t.

Operators

ColorColors can be implicitly converted to and from Vector4.
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.
operator +Adds two colors together. Each component is added separately.
Vector4Colors can be implicitly converted to and from Vector4.