Search Unity

Scene loading best practicies?

Discussion in 'Addressables' started by Kolyasisan, Jun 28, 2020.

  1. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    Recently profiling our project we've noticed a certain behaviour with how addressables load scenes. Specifically, how Unity loads and activates the scenes, which is usually load all of the scenes that are already scheduled via Addressables.LoadSceneAsync() and only then activate them one by one. There's not a single time when the profiler showed both the main thread busy with scene activation and the PreloadManager to be busy with loading.

    I wanted to ask if this is a normal behaviour. If not, then how can we mitigate it?
     
    Adrien_Danglard likes this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    I'll forward this over to the team for them to take a look, and share any guidance they kick my way.
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053

    Unfortunately, that is the nature of how the engine loads scenes, and has for a very long time. In addition to the threading limitations you mention, it's worth also noting that if you use allowSceneActivation=false, you cannot pre-load multiple scenes. As noted in the engine docs here https://docs.unity3d.com/ScriptReference/AsyncOperation-allowSceneActivation.html, if scene activation is off, the first scene to get to the ready-state will block the async operation queue.

    We have explored changing that engine behavior, but it's a bit outside the scope of our team, and difficult to do given that a lot of existing games & devs rely on that current behavior.

    -Bill
     
    Kolyasisan likes this.
  4. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    Sorry for a bit of a necrobump, but are there any updates on this?
    And I still want to ask for an advice on what would be the best approach to loading scenes via addressables to maximize the performance. Something tells me that just scheduling a bunch of async ops with true for allowing scene activation is not the most perfect idea.
    Thank you for your attention.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820