๐ฆ Serialization and Trunks
Short Description
Trunks store serialized Object Variable payloads and hydrate runtime instances on demand.
Long Description
The trunk system captures the authoritative default state of Object Variables into a compact payload, then rehydrates instances when requested. This lets you store many variable snapshots without keeping every UObject loaded in memory, while still supporting editor pin configuration metadata.
๐ Features
- Portable payloads that snapshot Object Variable state.
- Lazy runtime instantiation with caching.
- Hash and revision tracking for change detection.
๐ Usage Examples
FGorgeousObjectVariableSerializedPayload Payload;
if (MyVariable->SerializeToPayload(Payload))
{
Trunk.UpsertPayload(Payload.VariableIdentifier) = Payload;
}
Use the Object Variable trunk as a container for serialized variables when building editor tooling or runtime caches.
FGorgeousObjectVariableSerializedPayload
Stores the class, identifier, container type, and serialized bytes required to rebuild an Object Variable instance later.
This is a struct; assign properties directly on the payload.
Payload.VariableIdentifier = FGuid::NewGuid();
Payload.VariableClass = UString_SOV::StaticClass();
Payload.Touch();
FGorgeousObjectVariableTrunk::GetOrCreateRuntimeInstance
Rehydrates a runtime instance for a payload, returning a cached instance when one already exists.
| Parameter Name | Type | Description |
|---|---|---|
Identifier |
FGuid |
Payload identifier to load. |
Outer |
UObject* |
Outer used for the spawned instance. |
UGorgeousObjectVariable* Instance = Trunk.GetOrCreateRuntimeInstance(Payload.VariableIdentifier, Outer);
Best Practices
- Call
Touch()whenever serialized bytes change so caches invalidate correctly. - Store trunks on assets or subsystems that outlive the variables they serialize.
- Use
InvalidateCachewhen you mutate payloads outside the normal serialization path.
Troubleshooting
- If a variable rehydrates with stale data, ensure the payload revision is updated.
- If hydration fails, verify
VariableClassis set and loadable.