Skip to main content

Widget State

Base:
struct
Type:
FNWidgetState
Header File:
NexusUI/Public/NWidgetState.h

A lightweight key-value bag for bool, float, and FString values, used to snapshot and restore UMG widget state across navigation, layer changes, or save/load. Keys are stored in three index-aligned UPROPERTY array pairs per type, which keeps the struct USTRUCT-friendly without needing a container-of-variants.

Blueprint access is provided through UNWidgetLibrary. Persisted snapshots of many widget states live in FNWidgetStateSnapshot, used by the UNEditorUtilityWidgetSubsystem to restore editor utility widgets across sessions.

What It Is​

  • Three Parallel Bags: Strings, booleans, and floats each live in their own Keys / Values array pair. Lookups are linear scans over the keys array.
  • USTRUCT(BlueprintType): Can be passed across Blueprint boundaries and stored on UPROPERTY fields.
  • Self-Logging: DumpToLog() writes every entry to LogNexusUI for inspection.

API​

MethodEffect
HasString / HasBoolean / HasFloatReturns true when a value is stored under Key.
GetString(Key) / GetBoolean(Key, bDefault=false) / GetFloat(Key, Default=0.f)Returns the stored value, or the default when missing.
AddString / AddBoolean / AddFloatAppends a new entry without checking for an existing one; returns the new index.
SetString / SetBoolean / SetFloatUpdates the entry for Key if it exists, otherwise appends.
RemoveString / RemoveBoolean / RemoveFloatDrops the entry for Key if present.
ClearStrings / ClearBooleans / ClearFloats / ClearAllEmpties one or all of the bags.
OverlayState(Other, bShouldReplaceKeys)Merges every entry in Other into this state. When bShouldReplaceKeys is false (default), only missing keys are copied — existing keys are left untouched.
DumpToLogWrites the entire state to LogNexusUI as Display log entries.
info

Add* methods do not check for existing keys — calling AddString twice with the same key produces two entries, and subsequent Get* calls return the first one. Prefer Set* unless you specifically need the append-only behavior (e.g. when bulk-loading from a known-clean source).