ColorPalette API
The ColorPalette class is a ScriptableObject for generating and managing harmonious color schemes.
Enums
PaletteType
Defines color harmony generation algorithms:
public enum PaletteType
{
Complementary, // Two opposite colors
Triadic, // Three evenly spaced colors
Tetradic, // Four evenly spaced colors
Analogous, // Adjacent colors on wheel
SplitComplementary, // Base + two adjacent to complement
Monochromatic, // Single hue variations
Gradient, // Smooth transitions
Custom // User-defined colors
}
TextureLayout
Defines how colors are arranged in generated texture:
public enum TextureLayout
{
Horizontal, // Left to right strip
Vertical, // Top to bottom strip
Grid, // 2D grid layout
Radial, // Circular arrangement
Smooth // Continuous gradient
}
Properties
Palette Data
| Property | Type | Description |
|---|---|---|
PaletteName | string | Display name of the palette |
Type | PaletteType | Current harmony type |
BaseColors | Color[] | Seed colors for generation |
GeneratedColors | Color[] | Generated color array |
GeneratedTexture | Texture2D | Generated texture for sampling |
Settings | PaletteSettings | Generation configuration |
HandleOverrides | IReadOnlyList<PaletteHandleOverride> | Per-color adjustments |
Methods
| Method | Description |
|---|---|
void GeneratePalette() | Regenerates GeneratedColors and the cached texture using current base colors, type, and settings. |
void SetBaseColors(params Color[] colors) | Overrides the seed colors used by the generator. |
void SetPaletteType(PaletteType type) | Switches the harmony algorithm (Complementary, Triadic, etc.) and regenerates the palette. |
Texture2D GetOrCreateTexture() | Returns the cached palette texture, generating it on demand if needed. |
void RegenerateTexture() | Clears the cached texture so it will be rebuilt on next access. |
void SetHandleOverride(int index, float? saturation, float? value) | Applies per-swatch overrides for saturation and/or value. |
void ClearHandleOverride(int index, bool saturation, bool value) | Removes overrides for a specific swatch. |
void ClearAllOverrides(bool saturation, bool value, bool rebuild = true) | Clears overrides across all swatches (optionally regenerates). |
See the Code Examples for practical usage patterns.
Nested Classes
PaletteSettings
Configuration for palette generation:
[Serializable]
public class PaletteSettings
{
[Range(2, 64)]
public int ColorCount = 5; // Number of colors to generate
[Range(0f, 1f)]
public float SaturationVariation = 0.2f; // Saturation spread
[Range(0f, 1f)]
public float LightnessVariation = 0.3f; // Value/lightness spread
[Range(0f, 360f)]
public float HueShift; // Hue offset for variations
public TextureLayout Layout = TextureLayout.Horizontal;
public bool SmoothTransitions = true; // Blend between colors
public bool AutoSize = true; // Auto-calculate texture size
[Range(1, 2048)]
public int TextureWidth = 256; // Manual width if !AutoSize
[Range(1, 2048)]
public int TextureHeight = 256; // Manual height if !AutoSize
[Range(0, 270)]
public int RotationAngle = 0; // Rotate in 90° increments
}