Created
December 12, 2017 08:47
-
-
Save RChehowski/12f61370d53f1b9c09f275a554d0edcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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