Search Unity

How to transition scene to scene?

Discussion in 'Scripting' started by Wasiim, May 30, 2015.

  1. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    One thing i always wondered since starting to learn Unity3D is how do you script a scene transition when a certain event triggers?
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    You could have gotten an answer quicker if you just looked up a tutorial =P

    first, you have to go to File->Build settings and click "add current" to add the current scene to the list of "levels". Once each scene is in the list, it's level number is displayed to the right of it on the build settings menu.

    Now you can do any of these:
    1) Application.LoadLevel(levelNumber) - Destroys all game objects, then loads the level
    2) Application.LoadLevelAdditive(levelNumber) - Loads the level and keeps everything that's already there

    There's also "async" versions of both of those if you want the level to load (without pausing) while the game is still running. That said,
     
    Wasiim likes this.
  3. Wasiim

    Wasiim

    Joined:
    May 2, 2015
    Posts:
    228
    Thank you, good day to you Sir.