Page 1 of 1

Multi-Scene Workflow

Posted: Sun Jan 29, 2023 7:13 am
by Ishmhora
Hello,

I am working from a multiscene approach for my game. I have a semi-persistent scene that contains my player and a different scene that contains my NPCs. I want to be able to start the game and load a save data set for the player scene and a different save data set for the NPCs scene. So far I haven't needed to really break into the code and have just been using the auto save in the editor. Is there a way to differentiate filenames by scene and then load them based on file name? Or to create multiple file paths that are scene specific from the editor tools?

Apologies I'm certain this is something already answered somewhere but I haven't been able to find anything in the guides that got me in the right direction.

Re: Multi-Scene Workflow

Posted: Mon Jan 30, 2023 9:49 am
by Joel
Hi there,

If you're using Auto Save it will automatically create a unique key on a per-scene basis. However, if you want to achieve this with code you would simply set the filename parameter of the ES3.Save and ES3.Load methods to the name of your scene. Something along the lines of:

Code: Select all

ES3.Save("myKey", myValue, nameOfYourScene + ".es3");

Code: Select all

myValue = ES3.Load<Type>("myKey", nameOfYourScene + ".es3");
All the best,
Joel

Re: Multi-Scene Workflow

Posted: Tue Jan 31, 2023 2:50 am
by Ishmhora
So I'll likely have to break down and create some custom code. But just for reference. I have two scenes that I loaded and setup using the auto save independently for each scene. When I load both scenes simultaneously the only scene that saves appears to be the scene manager defined active scene. The second scene doesn't load or capture a scene specific save file. But both scenes changes are detected. The prefabs from the NPC scene get loaded into the player/game manager scene when the load happens. If I swap the active scene to the NPC scene it does the same in the reverse.

I've included here a few screen shots of my game setup and what happens on the save/load from the auto save setup. If I'm missing some setting for the auto save let me know. Otherwise I'll look to do some custom code for my handling.

Re: Multi-Scene Workflow

Posted: Tue Jan 31, 2023 9:58 am
by Joel
Hi there,

Unfortunately it's not possible for me to replicate this from what you've sent, and I wasn't able to replicate this at my end. Please could you replicate this in a new project with a simple scene using the latest version of Easy Save and private message it to me with instructions so I can see what is happening?

All the best,
Joel

Re: Multi-Scene Workflow

Posted: Tue Jan 31, 2023 11:33 pm
by Ishmhora
I can absolutely create a sample file! I'll send it over once I have it setup for you.

Re: Multi-Scene Workflow

Posted: Wed Feb 01, 2023 10:37 am
by Joel
Hi there, and thanks for sending that over, I've managed to replicate the issue from what you've sent.

Firstly you're using a very old version of Easy Save, so I recommend updating.

Secondly, because your Auto Save is set to load in Awake, it's loading before the reference manager for the scene has loaded in. Setting your Load event to Start in the Auto Save settings will resolve that.

However, I have also found a bug at Unity's end where the event indicating that the active scene has changed isn't called for an Editor Window, meaning that changes to the Save and Load event only apply to the first active scene. If you private message me your invoice number I can send over an update which resolves this, and then you will be able to set the Load Event for all of your scenes (after you make them active).

All the best,
Joel