Class ColorSwatchCollection
An immutable, ordered collection of named UnityEngine.Color swatches. Provides indexed access and case-insensitive name lookup. Used as the runtime representation of a ColorSwatchCollectionAsset.
Inherited Members
Namespace: Scylla.Core.Util.Palette
Assembly: ScyllaCore.dll
Syntax
public sealed class ColorSwatchCollection
Remarks
Unlike ColorPalette, swatch collections do not support semantic roles, tags, or perceptual nearest-color matching. They represent a flat quick-access list of colors as authored in the Chroma Swatches Library.
Constructors
ColorSwatchCollection(string, string[], Color[])
Creates a new immutable swatch collection from the specified entries.
Declaration
public ColorSwatchCollection(string name, string[] names, Color[] colors)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Human-readable collection name. Must not be null. |
| string[] | names | Parallel array of swatch names. Must not be null. |
| Color[] | colors | Parallel array of swatch colors. Must not be null. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If any argument is null. |
| ArgumentException | If the name and color arrays have different lengths. |
Properties
Colors
Gets a read-only span over all swatch colors (float precision) in collection order.
Declaration
public ReadOnlySpan<Color> Colors { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<Color> |
Count
The number of swatches in this collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
this[int]
Gets the color at the specified collection index.
Declaration
public Color this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based index. |
Property Value
| Type | Description |
|---|---|
| Color | The color at the specified index. |
Name
The human-readable name of this collection.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Names
Gets a read-only span over all swatch names, in collection order.
Declaration
public ReadOnlySpan<string> Names { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<string> |
Methods
GetName(int)
Gets the name of the swatch at the specified index.
Declaration
public string GetName(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based index. |
Returns
| Type | Description |
|---|---|
| string | The swatch name. |