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
| Function | Description |
|---|---|
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:
| Value | Scope |
|---|---|
EOBSDataRealm::Global | Persists across all OBS profiles |
EOBSDataRealm::Profile | The 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:
SetPersistentDatareturnsfalseif the supplied JSON is invalid (nothing is sent in that case). Passing an empty value clears the slot.