Scene loading at level 3

Hello! Total beginner here, so apologies if this is a stupid question. I’ve been trying to work this out for hours, reading everything I can, but it’s driving me crazy!

I have a very simple main menu, that is then supposed to take players into my main game when they press the spacebar. However, for some reason, the game the loads at Level 3, not Level 1.

Why might this be?

Here’s the code I’ve used for my main menu:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class MenuScript : MonoBehaviour {

// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void Update () {
    if (Input.GetKey(KeyCode.Space))
        SceneManager.LoadScene("_Complete-Game" , LoadSceneMode.Single);
    SceneManager.UnloadSceneAsync("MainMenu");
}

}

If anybody could please explain what I’ve done wrong, that would be fantastic!

Thanks.

Good day.

Is not a code problem.

You need to configure the scenes you want to include in your build. And select wich scene is the intial.

Do this by going at BuildSettings, The top scene (number 0) will be the 1st scene to load. Then all other scenes must be loaded by code during gameplay.

Ahh, i missunderstood your problem!

Dont do that loading and unloading codes. Load in regular way, not async. Once you get the solution, commence experimenting by loading async, but if you are commening in Unity, just use need to load the new scene; just do this :

 void Update () 
   {
         if (Input.GetKey(KeyCode.Space))
           {
             SceneManager.LoadScene(sceneName);
           }
    }

Of course, replacing sceneNAme by the real scene name, between " ", like this example:

 SceneManager.LoadScene("BattleLevel2");


Bye!! :smiley: