Skip to content

Color Scheme

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

Color Scheme

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 _night;

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

ColorScheme

[ManeStyle] 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.

ColorSchemeController

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

  • 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.

Inspector

The controller editor (ManeEditor) shows the scheme object field, then one row per palette color: swatch + list of graphics for that slot. No scheme → warning InfoBox, no rows. Changing the scheme asset rebuilds the rows.

Screenshot: color-scheme-asset.png — ColorScheme asset inspector (color array). Host at https://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-UnityUI/color-scheme-asset.png.

Screenshot: color-scheme-controller.png — controller with slot rows mapped to graphics. Host at https://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-UnityUI/color-scheme-controller.png.

Clone this wiki locally