How Do I Link Different Scenes?

I have a game where you roll a ball around and collect a certain amount of objects while trying to avoid obstacles and not fall off the given map. How do I link another level, so that when the player finishes the first round, they can automatically be taken to the next one, or get a choice to move to the next one? The more answers the better! Thanks in advance!

There is a fantastic Tutorial on this in the Live training sessions. Here is the link… Recorded Video Sessions on UI - Unity Learn

Super awesome and easy to follow. Good luck!

You need to add the scenes to “scenes in build” on the build settings window. Then on a script that lives on a gameobject in your scene yo have to call UnityEngine.SceneManagment.SceneManager.LoadScene(“YourSceneName”); when you want the scene to change. You can avoid the long line by adding using UnityEngine.SceneManagement; to the top of your script outside of the class and just use SceneManager.LoadScene(“YourSceneName”);.

I assume that you already made your scene and that you just need the script. If not, just reply and i will try to help. It should work!

First, create a Javascript and poste the following code:

var isQuitButton = false;

function OnMouseUp() {
    //Mark this checkbox if it is a Quit Button.
    if (isQuitButton) {
        //If the checkbox is marked, the game will close.
    else {
        //The level to load. Insert the number here.

Attach this to your button/collider/text/etc…
Note that you will need to make one script for each scene, as it is difficult to make one script for all the scenes in your game. After attaching the script to your button, you will see a checkbox saying “Is quit button”. If you have an exit button in your game, attach the script to it and mark the box. If it isn’t a quit button, just ignore. It is pretty simple, when you click the button, the game will load your scene.

As you might now, in the BUILD settings, you can attach the scenes of your game. Each scene has a number. For an example, if i want to load my tutorial scene, i will check in the build which number it has. If it has the number “2”, then i am going to use 2 in this part of the code: Application.LoadLevel(2);

Hope it helped!

File → New Scene?