What if we wish to save/load dynamically created and destroyed objects?

Great video. Question: What if we wish to save/load dynamically created and destroyed objects? The way I see it currently the foreach only identifies currently existing saveable entities. If I later create or destroy an object/prefab I’m assuming that it won’t be found with the FindObjectsofType?

Would a way around this be to perhaps store an array of objects each containing a prefab ID/string, and then re-create all the prefabs on load and initialize/modify them with their saved data?

That could work but is a little fragile if you change up your prefabs in any way. The links from the save file would all be broken even if you changed the links in your scenes/other prefabs.

My preferred way at the moment is to make the spawner responsible for storing the data about what it spawned. Then it can respawn objects when needed.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms