Logo

Styler Preset

Store reusable theme values in a StylerPreset asset

Overview

A StylerPreset asset holds the values shared by your UI. Components request entries by ID, which lets you create theme variants without changing each component’s references.

Styler Preset

Usage

In the Project window, choose Create -> Evo -> UI -> Styler Preset.

Add entries for your colors, fonts, audio, sprites, gradients, text styles, and shape styles.


Customization

Entry Types

TypeTypical use
AudioHover, click, open, and close sounds.
ColorText, surfaces, outlines, and state colors.
FontA font for each text provider, such as a TextMesh Pro font asset and a UniText font stack.
GradientShared color gradients.
SpriteReusable images and icons.
Text StyleTypography settings shared by text labels.
Shape StyleProcedural Shape appearance.

Fonts

A Font entry holds one font per text provider. With only TextMesh Pro installed, it shows a single Font Asset field; with UniText installed, it shows a TextMesh Pro and a UniText field. Components use the font that matches their text's provider, so one Font ID works with every provider. Font entries also pair fonts when converting existing text.

Shape Styles

A Shape Style’s Applies To flags select Graphic, Shape, Fill, Outline, Inner Shadow, and Outer Shadow groups. Use only the groups a style should own; the other settings stay local.

Keep On Global Apply

Turn on Keep On Global Apply under Settings for a preset that should not follow theme changes, such as a screen with its own look. Objects using this preset keep it when Styler.ApplyPreset() switches the theme, and they don't inherit Styler.PersistentPreset when enabled later. Styler.ApplyPresetTo() still changes them.

Managing Presets

Keep IDs consistent across themes. Use the Browser's ID Migrator when renaming entries that are already in use. Save user preferences separately; runtime preset changes do not save them for the next session.


Public API

Use StylerPreset in the Evo.UI namespace. Prefer TryGet...() when an entry may be absent.

Fields

NameTypeDescription
audioItemsList<Styler.AudioItem>Named audio entries.
colorItemsList<Styler.ColorItem>Named colors.
fontItemsList<Styler.FontItem>Named fonts, with fontAsset for TextMesh Pro and providerFonts for other providers.
gradientItemsList<Styler.GradientItem>Named gradients.
spriteItemsList<Styler.SpriteItem>Named sprites.
textStyleItemsList<Styler.TextStyleItem>Named text styles.
shapeStyleItemsList<Styler.ShapeStyleItem>Named Procedural Shape styles.
updateModeStyler.UpdateModeAdaptive or Always update behavior.
keepOnGlobalApplyboolKeeps objects on this preset when another preset is applied globally or inherited from PersistentPreset.

Methods

NameParametersDescription
TryGetColor()string itemID, out Color colorLooks up a color and reports whether the ID exists. Returns bool.
GetColor()string itemIDReturns the color for an ID. Returns Color.
SetColor()string itemID, Color colorSets an entry's color, adding the entry if it is missing.
AddColor()string itemID, Color colorAdds a named color.
RemoveColor()string itemIDRemoves a color and reports success. Returns bool.
TryGetFont()string itemID, TextBackend backend, out Object fontLooks up the entry's font for a text provider. The font is null when the entry has none for it. Returns bool.
GetFont()string itemID, TextBackend backendReturns the entry's font for a text provider, or null. Returns Object.
SetFont()string itemID, TMP_FontAsset fontSets an entry's TextMesh Pro font, adding the entry if it is missing.
TryGetShapeStyleItem()string itemID, out Styler.ShapeStyleItem shapeStyleItemLooks up a Shape Style entry. Returns bool.
GetShapeStyleItem()string itemIDReturns a Shape Style entry. Returns Styler.ShapeStyleItem.
AddShapeStyle()string itemIDAdds a Shape Style with the given ID.
RemoveShapeStyle()string itemIDRemoves a Shape Style. Returns bool.
TryGetTextStyleItem()string itemID, out Styler.TextStyleItem textStyleItemLooks up a Text Style entry. Returns bool.
AddTextStyle()string itemIDAdds a Text Style.
RemoveTextStyle()string itemIDRemoves a Text Style. Returns bool.

Example

StylerPresetExample.cs
using UnityEngine;
using Evo.UI;

public class StylerPresetExample : MonoBehaviour
{
    [SerializeField] private StylerPreset sourcePreset;
    [SerializeField] private GameObject panel;
    private StylerPreset runtimePreset;

    private void Start()
    {
        runtimePreset = Instantiate(sourcePreset);
        if (runtimePreset.TryGetColor("Accent", out var accent))
        {
            runtimePreset.SetColor("Accent", accent * 0.8f);
            Styler.ApplyPresetTo(runtimePreset, panel, true, 0.2f);
        }
    }

    private void OnDestroy()
    {
        // Keep the clone alive for as long as the panel uses it.
        if (runtimePreset != null)
            Destroy(runtimePreset);
    }
}

On this page