Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Addressables.LoadScene is not asynchronous?

Discussion in 'Addressables' started by 5argon, Oct 22, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I tried this method to load a scene by key. The screen freezes until the scene appears in the Hierarchy. Is there anyway so I can preload the scene asynchronously so that it is ready for activation later?
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Maybe the lag is not the scene load, but the scene activation. I think what I need is an equivalent of https://docs.unity3d.com/ScriptReference/AsyncOperation-allowSceneActivation.html in the old way.

    I looked into SceneProvider, in the end it uses the same static method SceneManager.LoadSceneAsync

    Screenshot 2018-10-22 20.32.47.png

    Normally I would immediately allowSceneActivation = false after LoadSceneAsync.

    I would like to make a new ISceneProvider that can delay the activation but the old operation stalling pattern is not fitting well with this new AsyncOperationBase. The behaviour of allowSceneActivation = false is weird, it stall the completion at 0.9 and magically block any other (old) AsyncOperation until it is resumed. Any possible blocking is out of place for the new Addressables API design.

    The best would be UT implementing a new Scene API that loads to 100% completion but returns a special, unactivated scene state, like right click > Unload Scene making it greyed out in edit mode. (Unfortunately there is no such state in the play mode.) Then I can call like `Scene.Activate()` later. Currently I have to camouflage the lag in loading screen, then hide all root game objects.