Thanks @Sedal45, that’s certainly interesting and I’ll take a look at UGameplayStatics and USaveGame - but I’d really like to understand how to use the Core serialization library (ie Engine/Source/Runtime/Core/Public/Serialization) directly and how it works.
I’ve found that if I wrap the FArchive in a FObjectAndNameAsStringProxyArchive then it works as expected and the UObject is serialized and deserializes correctly with this different format:
00000000: 0800 0000 436f 6d6d 656e 7400 0c00 0000 ....Comment.....
00000010: 5374 7250 726f 7065 7274 7900 0a00 0000 StrProperty.....
00000020: 0000 0000 0006 0000 0048 656c 6c6f 0003 .........Hello..
00000030: 0000 0069 6400 0c00 0000 496e 7450 726f ...id.....IntPro
00000040: 7065 7274 7900 0400 0000 0000 0000 0001 perty...........
00000050: 0000 0005 0000 004e 6f6e 6500 0000 0000 .......None.....
As you can see each UPROPERTYs is seralized as name, type and value with run-length encoded strings. (I’m not sure what the “None” is on the end.)
But looking at the code for FObjectAndNameAsStringProxyArchive I’m not sure I get why it works, whereas using FArchive (FFileReader / FFileWriter) directly doesn’t. It’s functions don’t seem to be called.
I’ve walked through the working loading call (MyObject2->Serialize through FObjectAndNameAsStringProxyArchive ) in the debugger and I can’t quite figure out where the fields are actually read into the object.