Struct ColorGradientData
Serializable data representation of a ColorGradient, suitable for Unity Inspector editing and JSON serialization. Provides bidirectional conversion with the immutable ColorGradient type.
Inherited Members
Namespace: Scylla.Core.Util.Palette
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public struct ColorGradientData
Remarks
Use ToColorGradient() to convert to an immutable gradient.
Returns null if the data is invalid (empty name or fewer than 2 stops).
Use FromColorGradient(ColorGradient) to create serializable data from an existing immutable gradient.
Fields
AlphaStops
Optional array of alpha stop data entries for independent transparency control. When empty or null, the gradient uses alpha values from the color stops.
Declaration
[Tooltip("Optional alpha stops for independent transparency control. Leave empty to use color stop alpha.")]
public ColorGradientAlphaStopData[] AlphaStops
Field Value
| Type | Description |
|---|---|
| ColorGradientAlphaStopData[] |
ColorSpace
Color space for smooth interpolation.
Declaration
[Tooltip("Color space used for interpolation (RGB, HSV, or Oklab).")]
public ColorGradientColorSpace ColorSpace
Field Value
| Type | Description |
|---|---|
| ColorGradientColorSpace |
Description
Short description of the gradient.
Declaration
[Tooltip("Optional description of this gradient's purpose.")]
public string Description
Field Value
| Type | Description |
|---|---|
| string |
Mode
Interpolation mode (smooth or stepped).
Declaration
[Tooltip("Smooth: interpolate between stops. Stepped: hard transitions.")]
public ColorGradientMode Mode
Field Value
| Type | Description |
|---|---|
| ColorGradientMode |
Name
Name of the gradient.
Declaration
[Tooltip("Human-readable name for this gradient.")]
public string Name
Field Value
| Type | Description |
|---|---|
| string |
Reduction
Smooth-mode "Reduction" slider value [0, 1]. Drives the per-stop IsMuted flags via the editor's reduction algorithm: at 0 nothing is muted, at 1 adjacent stops with small perceptual color distance are muted to collapse near-duplicates non-destructively. Only applied when Mode is Smooth.
Declaration
[Range(0, 1)]
[Tooltip("Smooth-mode Reduction slider - drives non-destructive muting of near-identical adjacent stops.")]
public float Reduction
Field Value
| Type | Description |
|---|---|
| float |
SteppedReduction
Stepped-mode reduction value [0, 1]. Independent of Reduction so users can tune step density without affecting smooth-mode muting. At 0 the runtime samples the smooth gradient with the maximum band count; at 1 the band count equals the active stop count. Only applied when Mode is Stepped.
Declaration
[Range(0, 1)]
[Tooltip("Stepped-mode Reduction slider - drives band count without modifying color stops.")]
public float SteppedReduction
Field Value
| Type | Description |
|---|---|
| float |
Stops
Array of gradient stop data entries.
Declaration
[Tooltip("Color stops defining the gradient.")]
public ColorGradientStopData[] Stops
Field Value
| Type | Description |
|---|---|
| ColorGradientStopData[] |
Tags
Optional asset-level tags for categorization and filtering of gradient assets (e.g., "Default", "Heat", "Sky"). Used by GetGradientsByTag(string) to retrieve groups of related gradients. Tags are case-insensitive.
Declaration
[Tooltip("Optional tags for asset categorization and filtering (e.g. 'Default', 'Heat').")]
public string[] Tags
Field Value
| Type | Description |
|---|---|
| string[] |
Methods
FromColorGradient(ColorGradient)
Creates serializable data from an immutable ColorGradient.
Declaration
public static ColorGradientData FromColorGradient(ColorGradient gradient)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorGradient | gradient | The gradient to convert. |
Returns
| Type | Description |
|---|---|
| ColorGradientData | A new ColorGradientData populated from the gradient. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
ToColorGradient()
Converts this serialized data to an immutable ColorGradient.
Returns null if the data is invalid.
Declaration
public ColorGradient ToColorGradient()
Returns
| Type | Description |
|---|---|
| ColorGradient | A new ColorGradient, or |