Removing specific savers from the save data
Posted: Sun Dec 06, 2020 10:58 pm
I have a series of scenes that are randomly generated when the player enters them. To do this I use a mix of static objects that are created on entry from prefabs (so they have Unique Saver Keys applied) and a bunch of Spawned Objects with Spawned Object Savers attached. Saving and Loading these scenes works perfectly right now. However, I can't think of a clean way to delete this data so when the player leaves and re-enters the scene it's brand new. (In theory I could just clear the Unique Keys and reassign them, but then I would have a bunch of obsolete data in the save file and it would keep growing and growing)
My current solution was to save these specific scenes to a special save file separate from the main save file, resulting in something like:
1) saveGame01.sav
2) saveGame01_GeneratedArea.sav
Then I just delete the "saveGame01_GeneratedArea.sav" when the player leaves the scene. However I realized this method is flawed because any data I want saved globally (player stats, time played, etc) would be applied to only the "saveGame01_GeneratedArea.sav" file while the player is in those scenes. It also just seems like a bad idea to be managing two save files for what is effectively one save slot.
So my question is: is there a way an efficient way to handle this? Such as removing specific save data (savers) from the save file (i don't know how this would work with spawned objects...) or perhaps somehow wiping all save data that is relevant to a specific scene index?
My current solution was to save these specific scenes to a special save file separate from the main save file, resulting in something like:
1) saveGame01.sav
2) saveGame01_GeneratedArea.sav
Then I just delete the "saveGame01_GeneratedArea.sav" when the player leaves the scene. However I realized this method is flawed because any data I want saved globally (player stats, time played, etc) would be applied to only the "saveGame01_GeneratedArea.sav" file while the player is in those scenes. It also just seems like a bad idea to be managing two save files for what is effectively one save slot.
So my question is: is there a way an efficient way to handle this? Such as removing specific save data (savers) from the save file (i don't know how this would work with spawned objects...) or perhaps somehow wiping all save data that is relevant to a specific scene index?