Skip to Content

Theme

Current visual theme id and flattened theme properties on Persistent (copied from configuration.themes[themeId] so they save in persistent.json). Publishes FACT_THEME_CHANGED when the id changes.

Adapter: UnityThemeAdapter.

State (Persistent keys)

Key / patternPurpose
currentThemeIdActive theme id (defaults to "normal" on launch and after run end)
Flat keys from theme JSONe.g. colors, grid alphas — copied with dot paths like background.grid.alpha (see CopyThemeValueToPersistent)

Also reads configuration.themes for source definitions.

How it looks in persistent.json

Theme id plus flattened properties copied onto Persistent (dot-path keys) so they survive saves — excerpt:

persistent.json
{ "Persistent": { "currentThemeId": "normal", "background.main": "#575763", "accent.neon": "#78D4FF", "primary.main": "#3399FA", "background.grid.alpha": 32 } }

Full key set depends on the active theme JSON under configuration.themes.

Events

Event idWhen
FACT_THEME_CHANGEDAfter SetCurrentTheme / theme id change (payload from GnosisThemeService)

Functions

FunctionParametersResult / side effects
GetCurrentThemeOk (state is source of truth; result payload minimal)
SetCurrentThemethemeId (string)Sets id, copies theme fields to Persistent, publishes FACT_THEME_CHANGED (see Events)

Usage example — SetCurrentTheme

ThemeService.Example1.cs
private void SwitchTheme(string themeId) { if (Context?.Store == null || Context.CallService == null) return; var args = GnosisNode.CreateObject(Context.Store); args.Set("themeId", themeId); CallService("Theme", "SetCurrentTheme", args); }

Public C# helpers

GetThemeProperty / GetThemePropertyFloat / GetCurrentThemeId / SetCurrentThemeId (alias SetThemeId) — read strings/floats from Persistent by property path.

Statistics

None dedicated; theme changes are event-driven.

Last updated on