I tried moving the SpawnedObjectManager to NewGameScene, but I'm still seeing the problem-- I think this time it's happening when I call SaveSystem.LoadScene(). I did find out a bit more about what's happening, though: wherever it's loading from when calling RecursivelyApplySavers(), it's getting updated whenever I change the position of spawned plants in NewGameScene. This means it's not just loading them from a saved file, but making clones of the plants in NewGameScene.
Still, I should always be using SaveSystem.LoadAdditiveScene() if I want to register savers when loading scenes additively, right? Or is there a way to get it to register existing objects rather than creating clones of them?
There's also a new problem I noticed-- only some plants get cloned/registered properly. I have different "types" of plants (thorn, fern, etc), with each type represented by a prefab. When I add a second fern, only the first fern gets cloned and registered by the SpawnedObjectManager. I changed the second's SpawnedObject key so it's not identical to the first, but that didn't fix it. I'm hoping this will be fixed by proxy when I figure out how to register the existing objects but I thought it was worth mentioning.
I have experimented with different scene load orders but right now I have:
Code: Select all
SaveSystem.LoadScene("NewGameScene"); // where the starting plants and spawned object manager are
I've also tried this to make sure the SpawnedObjectManager is initialized before the plants, but I get the same result:
Code: Select all
SaveSystem.LoadScene("Manager"); // where the SpawnedObjectManger is
...
SaveSystem.LoadSceneAdditive("TileScene"); // where starting plants are
It seems like it's close to working, but I suspect my use of SaveSystem.LoadSceneAdditive() or my subclass of SpawnedObjectManager aren't quite right for what I'm trying to do. I just want to load NewGameScene additively and register (not clone) the objects there, or if I do clone them, do so in a way that lets me add new ones via the editor, and reliably delete the originals after cloning.