Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question LoadSceneAsync(activateOnLoad = false) does not work

Discussion in 'Addressables' started by Verbess, Nov 21, 2020.

  1. Verbess

    Verbess

    Joined:
    Feb 10, 2018
    Posts:
    8
    Update
    Any code with LoadSceneAsync(activateOnLoad = false) does not work, and I have tested 3 version, check it at #2.
    Just like this, the scene will be activated when it has been loaded.


    private void Awake()
    {
    var loadSceneHandle = Addressables.LoadSceneAsync("MenuScene", LoadSceneMode.Single, false);
    }

    ========================================================================
    I just update Addressables from 1.8.5 to 1.16.12.

    And I found when I call a Addressables.LoadSceneAsync() function before Addressables.InstantiateAsync() function, it will activate the scene even though I set activateOnLoad = false.

    Just like below code

    private void Awake()
    {
    loadSceneHandle = Addressables.LoadSceneAsync("Scene", LoadSceneMode.Single, false);
    Addressables.InstantiateAsync("GameObject", Vector3.zero, Quaternion.identity);
    }

    So I wonder if this is my usage error or a bug.

    System version: macOS 11.0.1
    Unity version: 2019.4.15f1c1
    Addressables version: 1.16.12

    How to reproduce:
    1. New a scene and add the code Above to a gameobject
    2. make a anther scene and a gameobject Addressable
    3. Use the code to Load the scene and Instantiate the gameobject
     
    Last edited: Nov 21, 2020
  2. Verbess

    Verbess

    Joined:
    Feb 10, 2018
    Posts:
    8
    I degrade Addressables from 1.16.12 to 1.8.5 with Scriptable Build Pipeline from 1.15.1 to 1.7.3, and activateOnLoad = false works.

    So:
    Addressables 1.8.5 with Scriptable Build Pipeline 1.7.3, activateOnLoad = false works.
    Addressables 1.16.10 with Scriptable Build Pipeline 1.14.1, activateOnLoad = false does not work.
    Addressables 1.16.12 with Scriptable Build Pipeline 1.15.1, activateOnLoad = false does not work.


    And version 1.16.12 is verified by Unity 2019.4.15f1c1
     
  3. Verbess

    Verbess

    Joined:
    Feb 10, 2018
    Posts:
    8
    By the way, the param will be worked when called after InstantiateAsync() function.

    like this:

    await Addressables.InstantiateAsync<LocalizationManager>("GameObject", Vector3.zero, Quaternion.identity);
    var loadSceneHandle = Addressables.LoadSceneAsync("MenuScene", LoadSceneMode.Single, false);
     
  4. Verbess

    Verbess

    Joined:
    Feb 10, 2018
    Posts:
    8
    Alright,I have checked the document of new version. And it says activateOnLoad = false will block Any asynchronous request until the scene is allowed to activate. So it's the reason that activateOnLoad = false does not work? I just put the LoadSceneAsync function after InstantiateAsync function to make activateOnLoad = false works now. But I want to know the real reason.

    Waiting for reply, thanks.
     
    Denis-535 likes this.
  5. SleepyAgapornis

    SleepyAgapornis

    Joined:
    Sep 7, 2018
    Posts:
    23
    I'm having the same problem ... activateOnLoad=false gets completely ignored... I'm on Addressables 1.16.15 and I can't find a workaround to this problem other than just designing my game around activateOnLoad=true which isn't the optimal solution :( .
     
  6. Verbess

    Verbess

    Joined:
    Feb 10, 2018
    Posts:
    8
    I load the scene as the last one after all other loads with activateOnLoad = false to make it work. But do not know the real reason.
     
    Last edited: Dec 17, 2020
    SunnysideGames likes this.
  7. Denis-535

    Denis-535

    Joined:
    Jun 26, 2022
    Posts:
    21
    Why hasn't this been fixed until now?
     
  8. Denis-535

    Denis-535

    Joined:
    Jun 26, 2022
    Posts:
    21
    I tried to override SceneManagerAPI but it doesn't helped. So, it looks like the problem is inside SceneManager!!!
    Code (CSharp):
    1.     internal class MySceneManagerAPI : SceneManagerAPI {
    2.  
    3.         protected override AsyncOperation LoadSceneAsyncByNameOrIndex(string sceneName, int sceneBuildIndex, LoadSceneParameters parameters, bool mustCompleteNextFrame) {
    4.             var result = base.LoadSceneAsyncByNameOrIndex( sceneName, sceneBuildIndex, parameters, mustCompleteNextFrame );
    5.             result.allowSceneActivation = false;
    6.             return result;
    7.         }
    8.  
    9.         protected override AsyncOperation UnloadSceneAsyncByNameOrIndex(string sceneName, int sceneBuildIndex, bool immediately, UnloadSceneOptions options, out bool outSuccess) {
    10.             var result = base.UnloadSceneAsyncByNameOrIndex( sceneName, sceneBuildIndex, immediately, options, out outSuccess );
    11.             return result;
    12.         }
    13.  
    14.     }
     
  9. SunnysideGames

    SunnysideGames

    Joined:
    May 14, 2014
    Posts:
    23
    Hey we managed to fix our issue thanks to your message :).

    So yeah it's almost like if "activateOnLoad" was setting a global variable, and starting any asynchronous request during the loading would reset that variable value. Weird.
     
  10. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi all thanks for posting this issue. Is it possible to submit a bug report for this case?