Skip to content

Color Scheme

Ilia Petrov-Komotskii edited this page Oct 13, 2026 · 6 revisions

ColorScheme assets are palettes that applied to groups of MaskableGraphics by ColorSchemeController. Slot i maps to scheme color i.

Perfect for keeping colors consistent and hot-swapping color themes for simple graphics that can be colored with the component's color.

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[]. The 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 stops a running AnimateTo and calls Refresh() immediately.
  • Refresh() paints every graphic in slot i with scheme color i. A 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).

OnEnable refreshes, so an animation cut short by deactivation still ends on the target colors. The custom inspector's OnEnable also refreshes, so you see colors without entering Play mode.

AnimateTo

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

  • duration <= 0, no current scheme, or an inactive controller → snap via the ColorScheme setter.
  • A null target scheme, or a different Length from the current scheme → no-op.
  • Stops the previous animation, and continues from the current colors.

Clone this wiki locally