Description
The RgbaInt
property of the Color32
struct provides an integer representation of the color in the format 0xRRGGBBAA
. This format encodes the red, green, blue, and alpha (transparency) components of the color into a single 32-bit unsigned integer. Each component is represented by 8 bits, allowing values from 0 to 255 for each component.
Usage
Use the RgbaInt
property to retrieve or set the color as a 32-bit unsigned integer. This can be useful for operations that require a compact representation of color data, such as storing colors in a buffer or performing bitwise operations.
Example
// Example of using the RgbaInt property
Color32 color = new Color32();
color.r = 255; // Red component
color.g = 165; // Green component
color.b = 0; // Blue component
color.a = 255; // Alpha component (fully opaque)
// Get the integer representation
uint rgbaValue = color.RgbaInt;
// Output: 0xFFA500FF (Orange color)
// Set the color using an integer representation
color.RgbaInt = 0xFF0000FF; // Set to fully opaque red
// Access individual components
byte red = color.r; // 255
byte green = color.g; // 0
byte blue = color.b; // 0
byte alpha = color.a; // 255