Home > Enterprise >  SceneManager.LoadScene not loading scenes
SceneManager.LoadScene not loading scenes

Time:10-17

using UnityEngine;
using UnityEngine.SceneManagement;

public class Buttons : MonoBehaviour
{
    public void loadLevel()
    {
        SceneManager.LoadScene("Level");
    }
}

This is the code I am using, loadLevel() is supposed to load the scene Level when a button is clicked, this should be simple and I am not sure what is going wrong.

Thanks in advance!

CodePudding user response:

I guess you haven't added the scene "Level" in Build Settings (menu "File"-"Build Settings"). If it isn't in the build it can't be opened by LoadScene.

enter image description here

To add a scene you can either open it in the editor and then click on the "Add Open Scenes" button, or you can simply drag-and-drop the scene file from the Project-window to the "Scenes In Build".

CodePudding user response:

if you print the "level" variable before "SceneManager.LoadScene("Level");" what value you get?

  • Related