Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Load a scene

Discussion in 'Getting Started' started by samim99, Sep 4, 2019.

  1. samim99


    Apr 10, 2018

    In my game I have a map level scene, I want to keep this scene loaded until needed.

    As this scene has all the levels e.g locked, unlocked button it takes some time to load it, was thinking to load this at first scene and keep it until user clicks on levels button then show it.

    Now I have seen Additive mode and tried to use it but it wont work as it navigates straight to levels scene, have used allowSceneActivation but still cant make it work.

    Can someone please point me to right direction.
  2. Joe-Censored


    Mar 26, 2013
    I would load the levels scene first, and just hide its UI when not needed. You additive load the actual level the player wants to play, and set it to the active scene.
  3. samim99


    Apr 10, 2018
    The idea is if somone click on levels button they dont need to wait for all buttons to render.

    when my Home scene loads I am loading map levels scene as below using Additive:

    Code (CSharp):
    1. var scene = SceneManager.LoadScene(1, LoadSceneMode.Additive);
    2. scene.allowSceneActivation = false;
    then when user clicks levels button I do:

    Code (CSharp):
    1. public void LoadMapLevels()
    2.     {
    3.         maplevel.allowSceneActivation = true;
    4.         Scene loadedMapLevel = SceneManager.GetSceneByName("MapLevel");
    5.         if (loadedMapLevel.isLoaded)
    6.         {
    7.             SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(0));
    8.             SceneManager.SetActiveScene(SceneManager.GetSceneAt(1));          
    9.         }
    10.     }
    As the scene is not loaded and only loads when user clicks the levels button it still takes long to load map levels. How do I load it additive and not navigate and just set it inactive?