Using Save Game functionality with UObjects
I followed the documentation regarding Unreal's built-in support for save games. I subclassed USaveGame and added some pointers to UObject-derived classes to be serialized. e.g.
However, it doesn't look like the data that Data1 points to is getting serialized. I have an array of FString's in one of my UObject-derived classes, and I'd expect to see those strings if I opened the save file with a hex editor.
I was just wondering how to serialize the UObject-derived classes that the pointers point to. I appreciate any insight anyone may have!
After a bit of digging into engine code, I think I solved the problem (at least for my use case)!
Subclass the existing FMemoryWriter class and override the following operator as follows...
FTraversingObjectWriter is the new class I wrote. This solution seems to work even if I reorder the properties in my class declaration. It also appears to work with arrays of UObject pointers.
I'll leave the implementation of the inverse operation as an exercise to the reader. One can go about this by doing the following...
answered Nov 12 '16 at 10:17 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here