-
Notifications
You must be signed in to change notification settings - Fork 0
FGMPStructUnion
A value whose UScriptStruct type is decided at runtime, that still behaves like a first-class UE value.
Declared in Plugins/GMP/Source/GMP/Classes/GMPUnion.h:144
USTRUCT(BlueprintType, BlueprintInternalUseOnly,
meta = (HasNativeMake = "/Script/GMP.GMPStructLib:MakeStructUnion"))
struct FGMPStructUnion
{
UScriptStruct* GetScriptStruct() const;
FName GetTypeName() const;
bool IsValid(const UScriptStruct* InType = nullptr, uint32 ArrayIdx = 0) const;
template<typename T>
bool GetDynamicStruct(T& Data, uint32 Index = 0) const;
GMP_API bool Serialize(FArchive& Ar);
GMP_API bool Serialize(FStructuredArchive::FRecord Record);
GMP_API bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess);
GMP_API bool Identical(const FGMPStructUnion* Other, uint32 PortFlags = 0) const;
GMP_API void AddStructReferencedObjects(FReferenceCollector& Collector);
};The last four methods, via TStructOpsTypeTraits:
| Method | Consequence |
|---|---|
Serialize |
works in save games and asset serialisation |
NetSerialize |
replicates, with UPackageMap handling object references |
Identical |
property comparison and delta detection behave correctly |
AddStructReferencedObjects |
objects inside the held struct are visible to the garbage collector |
Without the last one a stored payload holding an object reference would be collected out from under you. This is why StoreObjectMessage can safely keep a message alive indefinitely.
It holds either one value or N values of the same runtime type — GetDynamicStruct and IsValid both
take an index, and GetArrayNum() bounds it. That is what lets a stored or serialised message carry a list
without a second container type.

struct FGMPStoreSourceMsgs : public TMap<FSigSource, FGMPStructUnion> // GMPUnion.h:526This is the container behind StoreObjectMessage: keyed by source, holding the copied payload.
GetDynamicStruct<T>(Data) is checked — it returns false rather than reinterpreting if the held type is not
T. Check the result; do not assume.
IsValid(InType) tests the held type without extracting.
Access goes through the StructUnion node family — Set/Get StructUnion, StructTuple, DynStructOnScope. See UK2Neuron.
GMP · Reference wiki — one page per named thing. Guided introduction: project site · 中文站点 · measured dispatch stack Source: repository · README · README 中文
Pages here are generated from wiki/ in the main repository — edit there, not on the wiki.
Concepts
- Why a string key
- Dispatch layers
- Parameter compatibility
- Signature inference
- Key baking
- Transparent rewrite
- Jump tracing
Sending and listening
- NotifyMessage family
- ListenMessage family
- StoreObjectMessage
- MSGKEY
- FSigSource
- FSigHandle
- FGMPKey
- FGMPResponder
Dispatch internals
Reflection and data
Editor
Build