I don't understand how savers on spawned objects (managed throught SpawnedObjectManager and SpawnedObject) are supposed to work.
The SpawnedObjectManager records this data: prefabName, position, rotation
The SpawnedObject itself records no data, it only registers/unregisters with the SpawnedObjectManager
I don't see how savers on the spawned object get their save data. I can't assign a key to the saver in the prefab, obviously, as it would be the same across all instances. I likewise can't leave it empty so it uses the gameObject name because again there's no guarantee that that's unique. The SpawnedObjectManager doesn't save any keys from any savers - so how?
Additionally, I have a number of spawned objects that start existing in the level, but can be destroyed by the player. This part appears to work (i.e. when I load a game, they correctly don't exist).
Save System: How do savers on spawned objects work ?
-
- Posts: 145
- Joined: Mon Nov 23, 2020 6:35 am
Re: Save System: How do savers on spawned objects work ?
Hi,
Savers on spawned objects only work if you're spawning unique objects -- for example, randomly spawning two out of five unique boss NPCs for a boss fight.
In version 2.2.24, I can look into saving data on other spawned objects, too. (Work on 2.2.23 is wrapping up now.)
Savers on spawned objects only work if you're spawning unique objects -- for example, randomly spawning two out of five unique boss NPCs for a boss fight.
In version 2.2.24, I can look into saving data on other spawned objects, too. (Work on 2.2.23 is wrapping up now.)
-
- Posts: 145
- Joined: Mon Nov 23, 2020 6:35 am
Re: Save System: How do savers on spawned objects work ?
That explains why I didn't get it to work. I was trying to assign a unique key to each object using System.Guid but that resulted only in strange behavior.
I'll write my own saver in that case, and share it here for others.
I'll write my own saver in that case, and share it here for others.
Re: Save System: How do savers on spawned objects work ?
Sounds good.
My plan for 2.2.24 is to associate a unique System.Guid with each SpawnedObject's saver data so it can pull its saver data from the saved game data.
My plan for 2.2.24 is to associate a unique System.Guid with each SpawnedObject's saver data so it can pull its saver data from the saved game data.
-
- Posts: 145
- Joined: Mon Nov 23, 2020 6:35 am
Re: Save System: How do savers on spawned objects work ?
You're probably aware of https://blog.unity.com/technology/spotl ... references which does something interesting in this direction.
Re: Save System: How do savers on spawned objects work ?
Yes. The Dialogue System implements a similar kind of thing for scene events.