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.
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
| Type | Typical use |
|---|---|
| Audio | Hover, click, open, and close sounds. |
| Color | Text, surfaces, outlines, and state colors. |
| Font | A font for each text provider, such as a TextMesh Pro font asset and a UniText font stack. |
| Gradient | Shared color gradients. |
| Sprite | Reusable images and icons. |
| Text Style | Typography settings shared by text labels. |
| Shape Style | Procedural 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.
Renaming Entries
To rename an entry, type a new ID in its ID field and press Enter. Press Esc to cancel.
Components that use the old ID keep their values. The entry keeps the old ID as a former ID and shows Renamed from under its ID field. Until their references are updated, the components' ID dropdowns show the new name with the old one, such as Brand (was Primary).
If other presets have the same ID, a dialog asks whether to rename it there too. Choose Rename in All to keep your theme presets matching, or Only This Preset.
Entries added during the current Editor session are renamed without a former ID or a dialog, until a component picks them in a Styler dropdown.
| Button | Result |
|---|---|
| Update References | Opens the ID Migrator with the former ID and the new ID filled in, so you can replace the old ID in scenes and prefabs. |
| Clear | Removes the former IDs after a confirmation. Components that still use them show the ID as missing. |
Managing Presets
Keep IDs consistent across themes. 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. Methods that take an ID also accept an entry's former IDs (Styler.Item.formerIDs), so code written for an old ID keeps working after a rename. A current ID always takes priority over a former one.
Fields
| Name | Type | Description |
|---|---|---|
audioItems | List<Styler.AudioItem> | Named audio entries. |
colorItems | List<Styler.ColorItem> | Named colors. |
fontItems | List<Styler.FontItem> | Named fonts, with fontAsset for TextMesh Pro and providerFonts for other providers. |
gradientItems | List<Styler.GradientItem> | Named gradients. |
spriteItems | List<Styler.SpriteItem> | Named sprites. |
textStyleItems | List<Styler.TextStyleItem> | Named text styles. |
shapeStyleItems | List<Styler.ShapeStyleItem> | Named Procedural Shape styles. |
updateMode | Styler.UpdateMode | Adaptive or Always update behavior. |
keepOnGlobalApply | bool | Keeps objects on this preset when another preset is applied globally or inherited from PersistentPreset. |
Methods
| Name | Parameters | Description |
|---|---|---|
TryGetColor() | string itemID, out Color color | Looks up a color and reports whether the ID exists. Returns bool. |
GetColor() | string itemID | Returns the color for an ID. Returns Color. |
SetColor() | string itemID, Color color | Sets an entry's color, adding the entry if it is missing. |
AddColor() | string itemID, Color color | Adds a named color. If the ID is another entry's former ID, the new entry takes it over. |
RemoveColor() | string itemID | Removes a color and reports success. Returns bool. |
TryGetFont() | string itemID, TextBackend backend, out Object font | Looks 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 backend | Returns the entry's font for a text provider, or null. Returns Object. |
SetFont() | string itemID, TMP_FontAsset font | Sets an entry's TextMesh Pro font, adding the entry if it is missing. |
TryGetShapeStyleItem() | string itemID, out Styler.ShapeStyleItem shapeStyleItem | Looks up a Shape Style entry. Returns bool. |
GetShapeStyleItem() | string itemID | Returns a Shape Style entry. Returns Styler.ShapeStyleItem. |
AddShapeStyle() | string itemID | Adds a Shape Style with the given ID. |
RemoveShapeStyle() | string itemID | Removes a Shape Style. Returns bool. |
TryGetTextStyleItem() | string itemID, out Styler.TextStyleItem textStyleItem | Looks up a Text Style entry. Returns bool. |
AddTextStyle() | string itemID | Adds a Text Style. |
RemoveTextStyle() | string itemID | Removes a Text Style. Returns bool. |
Example
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);
}
}