I found a simpler solution
I can write objects to memory using FObjectWriter, and read them back using FObjectReader, and then serialize to the savegame object as byte arrays.
I don’t need the whole dynamic object stuff from a structured archive, nor from the linker loader, I just load data into a pre-determined object hierarchy I create as default subobjects on construction, so this works well!
USaveGameMine::USaveGameMine()
{
MyObject = CreateDefaultSubobject<UMyObjectClass>(this, FName(TEXT("MyObject")));
}
void USaveGameMine::Serialize(FArchive& Ar)
{
TArray<uint8> mem;
if (Ar.IsSaving()) {
FObjectWriter wr(MyObject, mem);
uint8 v = 0;
if ((int)mem.Num() < 1) {
UE_LOG(LogBlueprintUserMessages, Error, TEXT("Bad size of serialized archive: %d"), (int)mem.Num());
Ar << v;
return;
}
v = 1;
Ar << v;
uint32 sz = mem.Num();
Ar << sz;
Ar.Serialize(&mem[0], mem.Num());
}
else if (Ar.IsLoading()) {
uint8 ver = 0;
Ar << ver;
if (ver != 1) {
UE_LOG(LogBlueprintUserMessages, Error, TEXT("Bad version number in character save: %d"), (int)ver);
return;
}
uint32 size = 0;
Ar << size;
if (size < 1 || size > MAX_CHARACTER_SIZE) {
UE_LOG(LogBlueprintUserMessages, Error, TEXT("Bad size in character save: %d"), (int)size);
return;
}
mem.InsertUninitialized(0, size);
Ar.Serialize(&mem[0], size);
FObjectReader rd(MyObject, mem);
}
else {
Super::Serialize(Ar);
}
}
I have some more code to deal with more properties of the savegame and also set some status flags based on success/failure, but this should illustrate the concept well enough.