Skip to content

Desuq Cafe

Documentation menu

Persistent Data

OBS provides a plugin-owned key/value store. Use it to remember small bits of per-stream or per-profile state without shipping a separate config file alongside your project. Values persist across OBS restarts.

These functions are reached via GetClient()->GetConfig().

Functions

FunctionDescription
GetPersistentData(Realm, SlotName)Fetch a slot (async), fires OnPersistentDataReceived. Result is also cached.
SetPersistentData(Realm, SlotName, SlotValueJson)Store a JSON value (returns false if the JSON is invalid, and an empty value clears the slot)
SetPersistentDataString(Realm, SlotName, Value)Store a plain string value
GetCachedPersistentData(Realm, SlotName)Read a previously-fetched slot from the local cache

Realms

Realm is an EOBSDataRealm:

ValueScope
EOBSDataRealm::GlobalPersists across all OBS profiles
EOBSDataRealm::ProfileThe current profile only

Example

UInhyeongOBSConfig* Config = Subsystem->GetClient()->GetConfig();

// Store a plain string in the global realm.
Config->SetPersistentDataString(
    EOBSDataRealm::Global, TEXT("LastSceneTheme"), TEXT("Cozy"));

// Fetch it back later (async, handle in OnPersistentDataReceived).
Config->GetPersistentData(EOBSDataRealm::Global, TEXT("LastSceneTheme"));

// Or read the cached value directly after a prior fetch.
FString Cached =
    Config->GetCachedPersistentData(EOBSDataRealm::Global, TEXT("LastSceneTheme"));

Note: SetPersistentData returns false if the supplied JSON is invalid (nothing is sent in that case). Passing an empty value clears the slot.

See also