Table of Contents

Class UITKThemeManager

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

Applies the player's colour overrides to every registered UI Toolkit panel.

public static class UITKThemeManager
Inheritance
UITKThemeManager
Inherited Members

Remarks

The UI Toolkit replacement for CanvasCrawler, which walked a Canvas hierarchy and wrote colours onto Image, Text and Selectable components. The shape of the job is the same; what it walks is different. Panels are found by their theme USS class rather than by component type, which is both cheaper and more precise — .fish-bar__fill--hp names the health bar directly, where the crawler had to infer it from where an Image sat in the hierarchy.

Why inline styles and not the tokens. FishMMO-Theme.uss declares its palette as custom properties, which is the natural place for an override to land — but UI Toolkit exposes no runtime API for setting a custom property on an element, and a StyleSheet cannot be authored at runtime either. Custom properties are therefore an authoring convenience only. A live override has to be written as an inline style, which sits above USS in the cascade and is cleared with UnityEngine.UIElements.StyleKeyword.Null to hand control back.

What that costs. Inline styles have no pseudo-state, so an override applies to an element's resting appearance and its :hover / :active rules continue to come from the stylesheet. The Canvas theme crawler had the same limitation for the same reason — it wrote a Selectable's normal colour and left the ColorBlock transitions alone — so this is the behaviour being reproduced, not a shortfall against it.

Panels register on show rather than being swept globally, because each UIDocument owns a separate visual tree and there is no single root to walk from.

Properties

Current

The theme in force, or null when nothing is overridden.

public static UITKTheme Current { get; }

Property Value

UITKTheme

Methods

Apply(VisualElement)

Applies the current theme to one root, or clears overrides when none is set.

public static void Apply(VisualElement root)

Parameters

root VisualElement

The panel's root visual element.

ApplyToAll()

Repaints every registered root.

public static void ApplyToAll()

Register(VisualElement)

Puts a panel root under theme control and paints it immediately.

public static void Register(VisualElement root)

Parameters

root VisualElement

The panel's root visual element.

Reload()

Loads the theme from global configuration and applies it to everything registered.

public static void Reload()

Unregister(VisualElement)

Removes a panel root from theme control.

public static void Unregister(VisualElement root)

Parameters

root VisualElement

The panel's root visual element.

Events

OnThemeChanged

Raised after the theme changes and every registered root has been repainted.

public static event Action OnThemeChanged

Event Type

Action