Logo

Styler

Share colors, typography, shapes, and audio across your UI

Overview

Styler keeps reusable visual and audio choices in a preset asset. Components look up those choices by ID, so changing a theme does not require editing every button, label, or panel separately.


Usage

Select a Styler Preset or open Tools -> Evo UI -> Styler Browser and choose a preset.

Define the colors, fonts, sprites, gradients, audio clips, text styles, and shape styles your UI needs.

Assign matching IDs on Styler Objects or components.

Apply the preset to your selection, scene, or project from the Browser.

For runtime calls (such as theme swapping), use the Public API.


Tips

Default Preset

The configured default is resolved through the Styler configuration under Resources. If there is no valid configured preset, the fallback is Resources/Styler Presets/Default. Use Tools -> Evo UI -> Open Default Styler or Ctrl+Shift+M to open it.

Interaction

Styler Object can map Disabled, Normal, Highlighted, Pressed, and Selected states to different colors or fonts. Procedural Shape can style its fill, outline, and shadows independently. See Styler Object interaction for setup.

Custom Components

Your own components can use the same preset and theme-switching workflow. Implement IStylerHandler to resolve preset values and apply them to your visuals, data, or effects.


Runtime Themes

Swapping Styler Preset at runtime is as easy as calling:

Styler.ApplyPreset(stylerPreset, isPersistent: true, transitionDuration: 0.25f);

A persistent runtime preset also applies to handlers registered later if they already have a preset assigned. It lasts only for the current session. Save the player’s theme preference separately if it should survive restarting the application.

Transitions blend supported colors and gradients. Fonts, sprites, shape geometry, and other values can change immediately.

Keep the same IDs across theme variants. For example, a button can request "Accent" in both a light and a dark preset while each preset supplies a different color.

Objects using a preset with Keep On Global Apply keep it during theme switches. Use it for screens with their own look; ApplyPresetTo() still changes them.


Public API

Use Styler in the Evo.UI namespace.

Setting PersistentPreset = null stops future inheritance without reverting styled objects. Applying a nonpersistent preset does not clear an earlier persistent selection. Use Register() and Unregister() to manage handlers rather than editing RegisteredHandlers directly.

Properties

NameTypeDescription
PersistentPresetStylerPresetRuntime override inherited on registration; null disables future inheritance.
RegisteredHandlersList<IStylerHandler>Registered IStylerHandler instances.

Methods

NameParametersDescription
GetDefaultPreset()bool generateLog = true, bool bypassCache = falseResolves the configured default, with optional logging and cache bypass. Returns StylerPreset.
ApplyPreset()StylerPreset newPreset, bool isPersistent = true, float transitionDuration = 0fApplies to registered handlers with optional runtime persistence and transition. Handlers on a preset with keepOnGlobalApply keep it.
ApplyPresetTo()StylerPreset newPreset, IStylerHandler target, float transitionDuration = 0fApplies to one handler without changing the persistent preset.
ApplyPresetTo()StylerPreset newPreset, GameObject target, bool includeChildren = true, float transitionDuration = 0fApplies to an object and optionally its children, including inactive children.
Register()IStylerHandler handlerAdds a live styling handler.
Unregister()IStylerHandler handlerRemoves a handler and cancels its color transition.
GetColor()StyleProvider provider, ColorMapping mapping, StylerPreset stylerPresetResolves a color mapping using Custom or Styler provider. Returns Color.
GetAudio()StyleProvider provider, AudioMapping mapping, StylerPreset stylerPresetResolves an audio mapping. Returns AudioClip.
GetFont()StyleProvider provider, FontMapping mapping, StylerPreset stylerPreset, TextBackend backendResolves a font mapping for a text provider, such as TextProvider.Find(text). Returns Object, or null when no font of that provider resolves. The obsolete overload without backend returns TMP_FontAsset.
GetSprite()StyleProvider provider, SpriteMapping mapping, StylerPreset stylerPresetResolves a sprite mapping. Returns Sprite.
GetGradient()StyleProvider provider, GradientMapping mapping, StylerPreset stylerPresetResolves a gradient mapping. Returns Gradient.

Example

StylerExample.cs
using UnityEngine;
using Evo.UI;

public class StylerExample : MonoBehaviour
{
    [SerializeField] private StylerPreset darkTheme;
    [SerializeField] private GameObject previewPanel;

    public void UseDarkTheme()
    {
        // Later registered UI can inherit this theme during the session.
        Styler.ApplyPreset(darkTheme, isPersistent: true, transitionDuration: 0.25f);
    }

    public void PreviewDarkTheme()
    {
        // Preview only this hierarchy, including inactive children.
        Styler.ApplyPresetTo(darkTheme, previewPanel, includeChildren: true, transitionDuration: 0.25f);
    }
}

On this page