Save System: Init scene when not loading a save game
Posted: Thu Oct 07, 2021 2:55 am
I'm doing a bunch of setup things in my main scene controller, some of which I want to not run or run differently when I'm loading a save game.
I know I can hook into saveDataApplied to wait until all savers are done.
But how do I figure out in Start() whether or not I'm loading a save game and should wait for it?
If that wasn't clear, here's a simplified example:
In Start() I populate a list of characters in the scene. These are stored in the save game because they can change during gameplay. But when I am entering the scene not from a save game, there's a default list I want to initialize (procedural generation). Obviously, it would be nonsense to run the generation, then receive the saveDataApplied event, throw it away and use the saved list. I'd like to essentially say "if I'm loading a game and waiting for the saver to run, skip this procedural generation part, we anyway won't need it".
Is there a "load game in progress" flag or something?
I know I can hook into saveDataApplied to wait until all savers are done.
But how do I figure out in Start() whether or not I'm loading a save game and should wait for it?
If that wasn't clear, here's a simplified example:
In Start() I populate a list of characters in the scene. These are stored in the save game because they can change during gameplay. But when I am entering the scene not from a save game, there's a default list I want to initialize (procedural generation). Obviously, it would be nonsense to run the generation, then receive the saveDataApplied event, throw it away and use the saved list. I'd like to essentially say "if I'm loading a game and waiting for the saver to run, skip this procedural generation part, we anyway won't need it".
Is there a "load game in progress" flag or something?