Game.Rendering.BlendColors
Assembly:
Assembly-CSharp.dll (most game code and mods for Cities: Skylines 2 are compiled into this assembly)
Namespace:
Game.Rendering
Type:
public struct
Base:
System.ValueType
Summary:
A simple value-type container for up to eight UnityEngine.Color values. Intended as a compact grouping of color slots that can be used for color blending, palettes, gradient stops, or to pass multiple colors together (for example to shaders, materials, or compute buffers). Each field is a UnityEngine.Color (RGBA floats).
Fields
-
public UnityEngine.Color m_Color0
Primary color slot 0. Typically the first color in a palette or blend set. -
public UnityEngine.Color m_Color1
Color slot 1. Used as the second entry in the blend/palette. -
public UnityEngine.Color m_Color2
Color slot 2. -
public UnityEngine.Color m_Color3
Color slot 3. -
public UnityEngine.Color m_Color4
Color slot 4. -
public UnityEngine.Color m_Color5
Color slot 5. -
public UnityEngine.Color m_Color6
Color slot 6. -
public UnityEngine.Color m_Color7
Color slot 7. Last available slot in this struct.
Properties
- This struct defines no properties; it exposes eight public fields. Use the fields directly or wrap the struct with helper code if you need computed properties or validation.
Constructors
public BlendColors()
No explicit constructor is defined in the source. As a C# struct, it has the implicit default constructor that initializes each Color field to the default UnityEngine.Color (RGBA all zero). To populate values, use an object initializer or assign fields after construction.
Example:
var colors = new BlendColors {
m_Color0 = Color.red,
m_Color1 = Color.green,
m_Color2 = Color.blue
};
Methods
- This struct defines no methods.
Notes and interoperability tips: - UnityEngine.Color is a struct of four floats (RGBA). BlendColors is therefore a tightly packed sequence of floats and is suitable for direct memory copies or for uploading to GPU buffers (ComputeBuffer/StructuredBuffer) as long as the receiving shader's layout matches. - When sending this struct to shaders or native code, ensure the expected ordering and padding (Unity usually uses float4 per Color) and consider using MaterialPropertyBlock.SetVectorArray or a ComputeBuffer of a matching struct. - Because this is a plain struct with public fields, it is cheap to copy and can be used in arrays or passed by value.
Usage Example
// Create and populate a BlendColors instance
var blend = new BlendColors {
m_Color0 = Color.white,
m_Color1 = new Color(1f, 0.8f, 0.6f, 1f),
m_Color2 = Color.gray,
m_Color3 = Color.clear // transparent
};
// Example: convert to Vector4 array for shader upload
Vector4[] colorVectors = new Vector4[] {
(Vector4)blend.m_Color0,
(Vector4)blend.m_Color1,
(Vector4)blend.m_Color2,
(Vector4)blend.m_Color3,
(Vector4)blend.m_Color4,
(Vector4)blend.m_Color5,
(Vector4)blend.m_Color6,
(Vector4)blend.m_Color7
};
// Set to material using a vector array (shader must expect an array of float4)
myMaterial.SetVectorArray("_BlendColors", colorVectors);