Page 1 of 1

SaveSystem.addedScenes and loading games

Posted: Mon Feb 21, 2022 12:47 pm
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.

Re: SaveSystem.addedScenes and loading games

Posted: Mon Feb 21, 2022 2:25 pm
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().

Re: SaveSystem.addedScenes and loading games

Posted: Mon Feb 21, 2022 3:54 pm
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!

Re: SaveSystem.addedScenes and loading games

Posted: Mon Feb 21, 2022 4:47 pm
by Tony Li
Glad to help!