About SaveSystem and DontDestroy and organize game

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

About SaveSystem and DontDestroy and organize game

Post by Fitbie »

Hi Tony! I only use your SaveSystem. Initially my question was: why some objects with DontDestroyOnLoad are saved and loaded, but others I encounter during the game are not. But now I realized that if i load the game from the main menu (where there is no player, all the canvases and other objects with dontDestroy) - just loads the scene and nothing else, which in principle is logical. 2 questions: How best to organize your game (in terms of saving / loading, maybe in a scene menu keep the player and all the canvases or something else),
And is it possible to save "found" objects (for example, in the middle of the game I met an object with dontDestroyOnLoad). Thank you!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: About SaveSystem and DontDestroy and organize game

Post by Tony Li »

Hi,

It's best to put the Save System component in the first scene, such as the main menu scene. It's probably a good idea to put the Dialogue Manager GameObject in the main menu scene, too. In fact, you can put the Save System component and its related components on the Dialogue Manager so you have fewer GameObjects to manage. This is what the Dialogue System's Demo scenes do.

If you do that, I recommend saving your customized Dialogue Manager GameObject as a prefab variant or a new prefab. If you save it as a prefab variant, it will inherit changes if the original Dialogue Manager prefab changes in a Dialogue System update. If you make it a new prefab, it won't inherit changes. (The Dialogue Manager prefab rarely changes between versions, though.) Then drop your prefab in the main menu scene and all scenes where you want to playtest the scene directly in the editor without having to come from the main menu scene.

To save "found" objects, you may be able to use a Spawned Object Manager. Please see the Save_System_Manual.pdf file for details on spawned objects. If that doesn't fit your needs, you can write a custom saver. To write a custom saver, duplicate SaverTemplate.cs and fill in your code where the comments indicate.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: About SaveSystem and DontDestroy and organize game

Post by Fitbie »

Okay, thank you and tell me please, player object and all objects with dontdestroyonload also keep in the main menu? It's just easier. Or better to spawn this objects?
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: About SaveSystem and DontDestroy and organize game

Post by Tony Li »

I think it's cleaner to keep those objects out of the main menu and either spawn them in each scene or place them in the scene at design time, like the Player GameObject in the Dialogue System's demo scenes.
Fitbie
Posts: 44
Joined: Tue Dec 07, 2021 6:30 pm

Re: About SaveSystem and DontDestroy and organize game

Post by Fitbie »

Got it, it's just that the problem is that I have a storyline sequential quest game and I can't just create them, they have to go through the game
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: About SaveSystem and DontDestroy and organize game

Post by Tony Li »

It's fine to keep them in the main menu scene then. You'll just want to make sure you hide or deactivate them when they're not supposed to be there. Alternatively, you could write a custom saver that records which of those special GameObjects have been spawned. When you load a game, the saver can respawn those objects.
Post Reply