Skip to content

Instantly share code, notes, and snippets.

@RChehowski
Created December 12, 2017 08:47
Show Gist options
  • Save RChehowski/12f61370d53f1b9c09f275a554d0edcd to your computer and use it in GitHub Desktop.
Save RChehowski/12f61370d53f1b9c09f275a554d0edcd to your computer and use it in GitHub Desktop.
FVariant FVarHandle::GetVariant()
{
// Holds the serialized value.
TArray<uint8> LocalValue;
// Write bytes to memory.
FMemoryWriter Writer(LocalValue, true);
Writer.Serialize(MemoryAddress, Property->GetSize());
FVariant Variant(LocalValue);
// HACK!!!
// Unfortunately, 'Type' is private member of 'FVariant'
// We've need to re-write type. To do so we must violate access modifiers.
*(reinterpret_cast<int32*>(&Variant)) = DeclaredVariantType;
// Check if our hack succeded.
check(Variant.GetType() == DeclaredVariantType);
return Variant;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment