Color

struct in UnityEngine

切换到手册

描述

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.

静态变量

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!

变量

aAlpha component of the color (0 is transparent, 1 is opaque).
b颜色的蓝色分量。
g颜色的绿色分量。
gammaA version of the color that has had the gamma curve applied.
grayscaleThe grayscale value of the color. (Read Only)
linearA linear value of an sRGB color.
maxColorComponentReturns the maximum color component value: Max(r,g,b).
r颜色的红色分量。
this[int]Access the r, g, b,a components using [0], [1], [2], [3] respectively.

构造函数

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

公共函数

ToString返回该颜色的整齐格式化的字符串。

静态函数

HSVToRGBCreates an RGB colour from HSV input.
Lerp在颜色 a 与 b 之间按 t 进行线性插值。
LerpUnclamped在颜色 a 与 b 之间按 t 进行线性插值。
RGBToHSVCalculates the hue, saturation and value of an RGB input color.

运算符

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.