Skip to content

Color Scheme

Ilia Petrov-Komotskii edited this page Sep 30, 2026 · 6 revisions

Named palettes (ColorScheme assets) applied to groups of MaskableGraphics by ColorSchemeController. Slot i maps to scheme color i.

Create an asset: Create → Mane Tools → Color Scheme.

using Mane.Unity.UI;
using UnityEngine;

public class ThemeSwitcher : MonoBehaviour
{
    [SerializeField] private ColorSchemeController _controller;
    [SerializeField] private ColorScheme _dayScheme;
    [SerializeField] private ColorScheme _nightScheme;

    public void GoNight()
    {
        _controller.ColorScheme = _nightScheme;           // snap, or...
        _controller.AnimateTo(_nightScheme, .35f);        // lerp (see caveats)
    }
}

ColorScheme

ScriptableObject. _colors is a Color[]. Indexer returns white if the index is out of range (or the array is null). Length is the array length.

ColorScheme asset screenshot

ColorSchemeController

Add Component → Mane Tools → UI → Color Scheme Controller.

ColorScheme Controller screenshot

  • ColorScheme setter calls Refresh() immediately.
  • Refresh() paints every graphic in slot i with scheme color i. Missing scheme or empty slots: no-op.
  • GetGraphicColor(i) is the first graphic in that slot (white if none).
  • SetGraphicsColor(i, color) writes every graphic in the slot.
  • SetColorSchemeWithoutRefresh stores the asset without painting (used while animating).

Awake refreshes. Editor OnEnable on the custom inspector also refreshes so you see colors without entering Play mode.

AnimateTo

Lerps current graphic colors toward colorScheme over duration seconds (Time.deltaTime). Default curve is linear.

  • duration <= 0 or there is no current scheme → snap via the ColorScheme setter.
  • Target scheme null, or different Length than the current scheme → no-op.
  • Stops previous animate coroutines.

Clone this wiki locally