Struct ColorPaletteData
Unity-serializable data representation of a ColorPalette. Used as the backing storage for ColorPaletteAsset and as an embedded field in ScriptableObjects that need Inspector-editable palettes (e.g., ScyllaUITheme).
Inherited Members
Namespace: Scylla.Core.Util.Palette
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public struct ColorPaletteData
Remarks
Serialization bridge. ColorPalette is immutable and not directly serializable by Unity. This struct holds the same data in a Unity-serializable format. Use ToColorPalette() to convert to the immutable runtime type, and FromColorPalette(ColorPalette) to convert back.
Inspector editing. Unity natively serializes UnityEngine.Color fields with color pickers, string fields with text input, and enum fields with dropdowns. Embedding a ColorPaletteData in a ScriptableObject produces a fully editable palette in the Inspector without custom drawers.
Constructors
ColorPaletteData(string, string, ColorPaletteEntryData[], string[])
Creates a new palette data from the specified values.
Declaration
public ColorPaletteData(string name, string description, ColorPaletteEntryData[] entries, string[] tags = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Palette name. |
| string | description | Palette description. |
| ColorPaletteEntryData[] | entries | Color entries. |
| string[] | tags | Optional asset-level tags. |
Fields
Description
A short description of this palette.
Declaration
[Tooltip("Short description of the palette origin or purpose.")]
public string Description
Field Value
| Type | Description |
|---|---|
| string |
Entries
The ordered array of color entries.
Declaration
[Tooltip("Color entries in palette order.")]
public ColorPaletteEntryData[] Entries
Field Value
| Type | Description |
|---|---|
| ColorPaletteEntryData[] |
Name
The human-readable name of this palette.
Declaration
[Tooltip("Palette name (e.g., 'Scylla UI Light', 'Player Custom').")]
public string Name
Field Value
| Type | Description |
|---|---|
| string |
Tags
Optional asset-level tags for categorization and filtering of palette assets (e.g., "UI", "Demo", "Retro", "Default"). Used by GetPalettesByTag(string) to retrieve groups of related palettes. Tags are case-insensitive.
Declaration
[Tooltip("Optional tags for asset categorization and filtering (e.g. 'UI', 'Demo', 'Retro').")]
public string[] Tags
Field Value
| Type | Description |
|---|---|
| string[] |
Methods
FromColorPalette(ColorPalette)
Creates a ColorPaletteData from an immutable ColorPalette.
Declaration
public static ColorPaletteData FromColorPalette(ColorPalette palette)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | palette | The palette to convert. Must not be null. |
Returns
| Type | Description |
|---|---|
| ColorPaletteData | A new serializable data representation. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If palette is null. |
ToColorPalette()
Converts this serialized data to an immutable ColorPalette.
Returns null if the data is structurally invalid (null or empty
Name, or null or empty Entries array).
Declaration
public ColorPalette ToColorPalette()
Returns
| Type | Description |
|---|---|
| ColorPalette | A new immutable ColorPalette instance built from this data,
or |
Remarks
Null name fallback. Individual entries with a null or
whitespace Name are assigned the
fallback name "Color_N" (where N is the zero-based index) and a
LogWarning(object) is emitted. This is a graceful
recovery intended to surface misconfigured Inspector data rather than
silently discard entries or throw.
Description null guard. A null Description is replaced with an empty string before passing to the ColorPalette constructor.