Save System and Spawn Objects Manager

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
alexjet1000
Posts: 18
Joined: Thu Oct 01, 2020 11:18 am

Save System and Spawn Objects Manager

Post by alexjet1000 »

Hi Tony!

Digging into the Save System i already set up all data saving except object instantiation at runtime.
Im wondering the best way to set this up because my game is composed by a village main scene and many (many) objects will be spawning and despawning at runtime, or additive scenes being loaded and unloaded.
Lets say each gameobject/scene holds -stages-.
A stage is like a chapter or event, and is a gameobject/scene that holds all gameobjects related to the event (timelines + binded gameobjects) and gets loaded or instantiated as the game progresses, then unloaded or destroyed.

Question is:

- Whats the best way to use the Spawn Objects Manager without it holding an inmense list with all possible runtime gameobjects. It is hard having all of them and be able to correctly debug/manage them in editor and avoid missing one.

- Can object managers be nested? So i have a global manager and then when restoring -stage- gameobjects, have inside other managers?

I understand this is a broad, implementation-related matter. I wanna know the limits and best use for the manager, so im also reading the base code, but maybe you can provide better insight.

Thank you for your constant support Tony.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save System and Spawn Objects Manager

Post by Tony Li »

Hi,

> - Whats the best way to use the Spawn Objects Manager without it holding an inmense list with all possible runtime gameobjects. It is hard having all of them and be able to correctly debug/manage them in editor and avoid missing one.
>
> - Can object managers be nested? So i have a global manager and then when restoring -stage- gameobjects, have inside other managers?

Multiple SpawnedObjectManagers are possible. Note that SpawnedObjectManager.instance will point to the most recent SpawnedObjectManager to come into existence. You'll need to override SpawnedObject's Start() and RecordDestruction() methods to add and remove their existence from the correct SpawnedObjectManager, since the default implementation adds and removes them from SpawnedObjectManager.instance.

For this reason, it's probably easiest to use one SpawnedObjectManager. Or maybe just take the code as a starting point and implement your own object manager to do the custom activity that you want. You could even grab the items from a Resources folder instead of SpawnedObjectManager's list -- but that might be a memory concern, since content in Resources folders are loaded into memory when the game starts.
Post Reply