Description
The Hex
property of the Color
struct provides a string representation of the color in the hexadecimal format. This format is expressed as "#RRGGBB[AA]", where "RR", "GG", "BB", and "AA" are two-digit hexadecimal numbers representing the red, green, blue, and alpha components of the color, respectively. The alpha component is optional and is included only if the color is not fully opaque.
Usage
Use the Hex
property to obtain a string that represents the color in a format commonly used in web development and graphic design. This can be useful for exporting colors to CSS or other systems that utilize hexadecimal color codes.
Example
// Example of using the Hex property
Color color = new Color(0.5f, 0.25f, 0.75f, 1.0f);
string hexValue = color.Hex;
// hexValue will be "#8040BF"