Page 1 of 1

Scene Portals with asynchronous scene transitions

Posted: Fri Nov 05, 2021 1:55 pm
by Geri860
Hi Toni,

Can you help me a little? Here is the scenerio:
I have a few smaller scenes, and I want to make it transition faster between them.
Essentially, the way I want to make it work is to tell a scene portal, that load the destination scene which is typed in the editor additive, and only load that scene when I enter the portal. I know how to make an async loading work, but not with the quest machine's scene portals.
I won't even need the scene transition animation, just to make it more snappier.

Is there a way to do that?

Re: Scene Portals with asynchronous scene transitions

Posted: Fri Nov 05, 2021 2:51 pm
by Tony Li
Hi,

You essentially want to stream parts of the world in and out as the player moves around? If so, you can make a subclass of ScenePortal and override the UsePortal method. Example:

Code: Select all

public override void UsePortal()
{
    if (isLoadingScene) return;
    isLoadingScene = true;
    onUsePortal.Invoke();
    //-- Don't use this: LoadScene();
    SaveSystem.sceneLoaded += OnSceneLoaded;
    SaveSystem.LoadAdditiveScene(destinationSceneName);
}

private void OnSceneLoaded(string sceneName, int sceneIndex)
{
    isLoadingScene = false;
    SaveSystem.sceneLoaded -= OnSceneLoaded;
}
You'll probably also want a script that unloads an additively-loaded scene when the player gets to a position that's far away from the scene. In that script, use SaveSystem.UnloadAdditiveScene().

SaveSystem.LoadAdditiveScene and UnloadAdditiveScene are like Unity's additive SceneManager.LoadScene/UnloadScene methods, except they also maintain save data properly.

Alternatives are to use the free but basic Scene Streamer asset, or the more advanced but paid SECTR Stream or World Streamer. If you use any of these alternatives, you'll need to write some code that tells the SaveSystem to record outgoing scenes' savers, and to apply saver data to savers in newly-loaded scenes.

Re: Scene Portals with asynchronous scene transitions

Posted: Tue Nov 09, 2021 6:14 am
by Geri860
Hey,

Thank you Tony, I've made it work!

Re: Scene Portals with asynchronous scene transitions

Posted: Tue Nov 09, 2021 7:23 am
by Tony Li
Happy to help! I'm glad you made it work. :-)