Search Unity

AsyncOperation.allowSceneActivation is actually static?

Discussion in 'Scripting' started by noamgat, Mar 31, 2016.

  1. noamgat

    noamgat

    Joined:
    Nov 22, 2009
    Posts:
    125
    I have a large scene that takes a while to load, and I want to preload it while the user is navigating in the menus (which are also multiple scenes).

    Lets say the scenes are called MenuScene1, MenuScene2 and BigScene and all add their content additively.

    In MenuScene1 I execute the code
    Code (CSharp):
    1. globalOperation = SceneManager.LoadScene("BigScene", LoadSceneMode.Additive)
    2. globalOperation.allowSceneActivation = false;
    And then I later transition to MenuScene2 with

    Code (CSharp):
    1. SceneManager.LoadScene("MenuScene2", LoadSceneMode.Additive)
    And when I am ready to transition to the big scene in MenuScene2 I do

    Code (CSharp):
    1. globalOperation.allowSceneActivation = true;
    However, when I do this, MenuScene2 doesn't load! It seems that setting allowSceneActivation = false on one scene loading operation applies this to every scene in the game. Is this intentional behaviour? Is this a bug? How am I supposed to preload large scenes if there are still scene navigation actions that have to be performed before I want to activate the large scene?
     
    Tomer-Barkan likes this.
  2. noamgat

    noamgat

    Joined:
    Nov 22, 2009
    Posts:
    125
    Added a sample project to illustrate the point.
    Open SmallScene1
    Click on Preload BigScene
    Then click on Load SmallScene2
    SmallScene2 will not load, despite the logs and state claiming that it should
     

    Attached Files:

  3. guywald

    guywald

    Joined:
    Aug 22, 2013
    Posts:
    13
    Check @Bunny83's answer in the following post (which seems logical):
    http://answers.unity3d.com/answers/1073667/view.html