SaveSystem.addedScenes and loading games

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hidingso
Posts: 26
Joined: Sat Sep 25, 2021 2:07 pm

SaveSystem.addedScenes and loading games

Post by hidingso »

Hello Tony,

I hope you are doing great.

Had a bit of a headscratcher with SaveSystem.addedScenes.

Scenario #1:

Code: Select all

Start Game -> Load Additive Scene "City" -> Save Game (Slot 1) -> Main Menu -> Load Game (Slot 1).
After this, SaveSystem.addedScenes shows "City" in it, while in reality it's not.

I "fixed it" by just initializing scenes with SceneManager when loading games.

Scenario #2:

Code: Select all

Start Game -> Load Additive Scene "City" -> Save Game (Slot 1) -> Main Menu -> Quit Game -> Start Game ->Load Game (Slot 1)
After this, SaveSystem.addedScenes is empty and loading scenes with SceneManager would end up me being unable Unload them using SaveSystem.

Well, again I "fixed it" by using SceneManager only when it's necessary (when scene is in addedScenes but not loaded).

This all seems really "hacky". I have this feeling I am doing something wrong? For a brief moment I used SceneManager to handle all the scene changes (to reduces the "hacky"), but I would prefer using SaveSystem to invoke Savers when loading/unloading scenes.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: SaveSystem.addedScenes and loading games

Post by Tony Li »

Hi,

When returning to the Main Menu, use SaveSystem.UnloadAdditiveScene() to unload the additively-loaded scenes -- or, if Unity automatically unloads those scenes when returning to the Main Menu, just call SaveSystem.addedScenes.Clear().
hidingso
Posts: 26
Joined: Sat Sep 25, 2021 2:07 pm

Re: SaveSystem.addedScenes and loading games

Post by hidingso »

Tony Li wrote: Mon Feb 21, 2022 2:25 pm Hi,

When returning to the Main Menu, use SaveSystem.UnloadAdditiveScene() to unload the additively-loaded scenes -- or, if Unity automatically unloads those scenes when returning to the Main Menu, just call SaveSystem.addedScenes.Clear().
Gosh, this is embarrassing.

I treated the get-only variables as const/read-only. Thank you, again!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: SaveSystem.addedScenes and loading games

Post by Tony Li »

Glad to help!
Post Reply