Should I clear arrays of pointers before saving struct to GameSave?

What are you using GetObjectsWithOuter() with ? The entire current World ?
GameInstance is not part of the world, which is also why it preserves data between levels.

What’s the Outer for your objects ? That’s for you to specify when you create them (unless they are actors, then outer = world).

It shouldn’t matter if stuff is in TransientPackage or not. If I understand this plugin correctly you first call Actor/ObjectSaver with all the actors/objects you need, which will serialize and store them into TArray<FObjectRecord>, then you call SaveGameToSlot which will save the TArray to disk. Inter-dependencies within saved objects should resolve fine, external dependencies won’t.

Also as a side note, that system uses the same serializer as SaveGame so the same rules as previously discussed apply - only UProperties are serialized. Additionally, it will only save UProperties marked with the “SaveGame” flag.

Gonna need more info - what are you saving, what are you restoring, what are the error messages when they fail ?


I think you should be able to create all your objects with Outer=GameInstance, and then serialize them using GetObjectsWithOuter(GameInstance). Avoid serializing the GameInstance itself. If I get this right you need to emplace GameInstance into the PersistentOuters array (say, at index 0) before saving. And before restoring, also emplace the GameInstance into PersistentOuters at the same index, so the deserializer can resolve it with actual object.

Recap (again this is from my understanding, could be wrong)
Saving :

  • create save game object
  • set SaveGame.PersistentOuters[0] = GameInstance
  • gather objects to save via GetObjectsWithOuter(GameInstance)
  • call UObjectArraySaver with gathered objects
  • SaveGameToSlot

Restoring :

  • SaveGame = LoadGameFromSlot
  • set SaveGame.PersistentOuters[0] = GameInstance
  • call UObjectsPreloader
  • call UObjectDataLoader