The Item
property of the Color
struct represents a single component of the color, such as red, green, blue, or alpha, as a float
value. This property is used to access or modify the individual components of a color object.
The Item
property of the Color
struct represents a single component of the color, such as red, green, blue, or alpha, as a float
value. This property is used to access or modify the individual components of a color object.
Use the Item
property to get or set the value of a specific color component. The property is indexed, allowing you to specify which component to access by its index:
0
for the red component1
for the green component2
for the blue component3
for the alpha componentNote that this property is marked with the JsonIgnore
attribute, meaning it will be ignored during JSON serialization and deserialization.
Color color = new Color(0.5f, 0.4f, 0.3f, 1.0f); // Accessing the red component float redComponent = color[0]; // Modifying the green component color[1] = 0.6f; // Accessing the blue component float blueComponent = color[2]; // Modifying the alpha component color[3] = 0.8f;