For some reason I like to make more work for myself and have been going through the lessons in Unity 5.3. In Unity53, Application.LoadLevel is deprecated (marked for deletion by Unity) and been replaced with a new class called SceneManagement.LoadScene. Following the API Scripting Manual and the unity forums, I believe I’ve set up my code correctly. However, the buttons don’t actually work. To make matters worse, I don’t get any errors.
One potential clue is the note that SceneManager uses a different method to load a scene in a runtime build or in the editor (unless I’m misunderstanding). I’ve tried both LoadScene and OpenScene but neither seems to work. I’d rather solve the problem than run from it and go back to Unity46, but maybe that’s the better option. Any advice? Here is my code:
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class LevelManager : MonoBehaviour {
// load the game level
public static void loadLevel(string name){
Debug.Log("Level load requested for: "+name);
SceneManager.LoadScene("Game");
}
// process a request to quit the application
public void quitRequest(){
Debug.Log("Quit request has been received from quit button");
}
}
2 Likes
I think Doh! is the only proper response to this. For some reason, I guess I was thinking ahead, I made my loadLevel method global. The word static was preventing the script from functioning properly. I removed it, and it works now using LoadScene.
You did better than me. When I messed up and had a similar effect (buttons didn’t respond, not even highlight and there was no obvious debugging either) it was because I had stupidly deleted the EventManager 
I’m sure when I get to the really complex stuff I’m going to create all kinds of errors that no one has seen or, more likely, EVERYONE has seen.
Hi… I read your code and i notice that you’re giving directly the string “Game” to the method SceneManager.LoadScene(). I think would be better (and correct) if you give the string variable rather than a string constant. Then you can reuse the script only by giving the names of the scenes in the text box corresponding to the “name” parameter in the editor.
Sorry by my english, it is not my native language… 
Never mind, solved it already 
Hi Peregrin Tux,
I have my code now similar to CraigItsFryday. If I write SceneManager.LoadScene(“Game”); all works fine, but as soon as I replace “Game” with name, I get the error: Scene ‘’ (-1) couldn’t be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
Any idea why that is?
Also in the line: Debug.Log("Level load requested for: "+name);
the scene name does not get plotted to the console.
Hi! I’m sorry for the delay in answering. I see that you have solved your problem, anyway if someone has the same problem, you probably solved it by adding your scenes to the “Build Settings” window. Did you solve it that way?
No, I had the scenes already in the Build settings, but I somehow missed the part, where we had to call the scene name inside the OnClick() event handler
