Search Unity

Instantiating Objects with Multiple Active Scenes

Discussion in 'Scripting' started by Michael_Waltham, May 25, 2017.

  1. Michael_Waltham

    Michael_Waltham

    Joined:
    Aug 20, 2014
    Posts:
    31
    I am currently using the SceneManager.LoadAsync method to create a loading screen system. Here is the level transition process in a nutshell:

    * Load the loading screen while unloading the current level.
    * Play some cool UI animations in the loading screen while SceneManager.LoadAsync loads the next level.
    * When the next level is finished loading, I unload the loading screen scene.

    The problem is, all objects that are instantiated in the Start methods of the new level are for some reason attached to the loading screen scene and are deleted when it is unloaded. How to I Instantiate an object and link it with a particular scene?
     
  2. mikael_juhala

    mikael_juhala

    Joined:
    Mar 9, 2015
    Posts:
    247
  3. Michael_Waltham

    Michael_Waltham

    Joined:
    Aug 20, 2014
    Posts:
    31
    Perfect, thanks for the reference. Can't believe I missed that while looking over the docs.