Page 1 of 1

Auto save - Saving current scene and loading back into it

Posted: Fri Nov 12, 2021 1:41 am
by manta__fanta
Hi,

What is the proper way to load into the last saved scene from a main menu button (using autosave)?

If I call this using the main menu "load" button, nothing happens:

Code: Select all

ES3AutoSaveMgr.Current.Load();
So I tried doing this workaround, but it seems a bit buggy:

I'm saving using an on-screen button, which uses ES3's autosave, then saves the current scene manually as "savedScene":

Code: Select all

    public string currentScene;

    public void Save()
    {
        ES3AutoSaveMgr.Current.Save();
        currentScene = SceneManager.GetActiveScene().name;
        ES3.Save("savedScene", currentScene);
    }   
Then on my main menu "load" button I load back into "savedScene":

Code: Select all

    public string sceneToLoad;

    public void Load()
    {
        sceneToLoad = ES3.Load<string>("savedScene");
        SceneManager.LoadScene(sceneToLoad);
    }
Then in my scene I load the ES3 autosave values for player position, etc. on Start:

Code: Select all

    public void Start()
    {
        ES3AutoSaveMgr.Current.Load();
    }
Am I going about this correctly? Or is there an easier, simpler way to do this?

Thanks!

Re: Auto save - Saving current scene and loading back into it

Posted: Fri Nov 12, 2021 8:23 am
by Joel
Hi there,

The way you’ve described is the correct way of going about it. Auto Save is for saving and loading Components in a scene, so you need to be in the scene for Auto Save to be able to load.

All the best,
Joel

Re: Auto save - Saving current scene and loading back into it

Posted: Fri Nov 12, 2021 4:22 pm
by manta__fanta
That's great to hear, thank you!