Page 1 of 1

Addressables during save/load?

Posted: Sun Oct 11, 2020 6:23 pm
by timbecile
Hi Tony,

I've moved my levels into addressables and wondered if your save/load system inside the Dialogue system has any support for that?

If so, how is it implemented?

Re: Addressables during save/load?

Posted: Sun Oct 11, 2020 7:52 pm
by Tony Li
Hi,

Are you talking about actual scene files?

What's the reason for moving them into Addressables, unless you're pulling them in from a source external to the build?

The Dialogue System's save system uses SceneManager.LoadSceneAsync, so as long as your system is fine with that, then there should be no problem.

Re: Addressables during save/load?

Posted: Sun Oct 11, 2020 10:22 pm
by timbecile
There was a couple reasons to move to addressables. Mostly for the memory savings because Unity's horrible shader management. But also to allow for player modding of my game.

The load command for addressables is

Addressables.LoadSceneAsync(scene, LoadSceneMode.Single).Completed += SceneLoadComplete;

which is a different one from SceneManager.LoadSceneAsync.

Re: Addressables during save/load?

Posted: Sun Oct 11, 2020 10:46 pm
by Tony Li
I'll look toward supporting that in a future update. In the meantime, you could modify SaveSystem.cs and replace the SceneManager calls with Addressables calls.

Re: Addressables during save/load?

Posted: Sun Oct 11, 2020 11:59 pm
by timbecile
that's a perfect solution. I need a bool anyway because some levels still load the old fashioned way.

Thanks Tony!

Re: Addressables during save/load?

Posted: Mon Oct 12, 2020 9:23 am
by Tony Li
Sounds good. This way SaveSystem wraps up the underlying load method (Addressables or SceneManager) so you don't have to think about it.

Version 2.2.12 just wrapped up and should be on the Asset Store in the next few days. I'll try to schedule this addition into version 2.3 if possible.

Re: Addressables during save/load?

Posted: Mon Oct 12, 2020 3:38 pm
by timbecile
Tony, where should I save the bool so I know it hits the right load command?

Re: Addressables during save/load?

Posted: Mon Oct 12, 2020 3:57 pm
by Tony Li
Hi,

I haven't yet worked out the details of how I plan to implement it. But, off the top of my head, I might use the scripting define symbol USE_ADDRESSABLES to try addressables first. Maybe write two versions of the LoadSceneInternal(string sceneName) method:

Code: Select all

#if USE_ADDRESSABLES
    private static IEnumerator LoadSceneInternal(string sceneName)
    {
        ... (try using addressables; failing that, use SceneManager) ...
    }
#else
    private static IEnumerator LoadSceneInternal(string sceneName)
    {
        ... (original method in SaveSystem.cs) ...
    }
#endif