struct Color32

A 32 bit color struct! This is often directly used by StereoKit data structures, and so is often necessary for setting texture data, or mesh data. Note that the Color type implicitly converts to Color32, so you can use the static methods there to create Color32 values!

It’s generally best to avoid doing math on 32-bit color values, as they lack the precision necessary to create results. It’s best to think of a Color32 as an optimized end stage format of a color.

Instance Fields and Properties

Byte a Color components in the range of 0-255.
Byte b Color components in the range of 0-255.
Byte g Color components in the range of 0-255.
Byte r Color components in the range of 0-255.

Instance Methods

Color32 Constructs a 32-bit color from bytes! You may also be interested in Color32.Hex.
ToString Mostly for debug purposes, this is a decent way to log or inspect the color in debug mode. Looks like “[r, g, b, a]”

Static Fields and Properties

Color32 Black Pure opaque black! Same as (0,0,0,255).
Color32 BlackTransparent Pure transparent black! Same as (0,0,0,0).
Color32 White Pure opaque white! Same as (255,255,255,255).

Static Methods

Hex Create a color from an integer based hex value! This can make it easier to copy over colors from the web. This isn’t a string function though, so you’ll need to fill it out the whole way. Ex: Color.Hex(0x0000FFFF) would be RGBA(0,0,255,255).


// You can create a color using Red, Green, Blue, Alpha values,
// but it's often a great recipe for making a bad color.
Color32 color = new Color32(255, 0, 0, 255); // Red

// Hue, Saturation, Value, Alpha is a more natural way of picking
// colors. You can use Color's HSV function, plus the implicit
// conversion to make a Color32!
color = Color.HSV(0, 1, 1, 1); // Red

// And there's a few static colors available if you need 'em.
color = Color32.White;

Creating color from hex values

Color   hex128 = Color  .Hex(0xFF0000FF); // Opaque Red
Color32 hex32  = Color32.Hex(0x00FF00FF); // Opaque Green

Found an issue with these docs, or have some additional questions? Create an Issue on Github!