Application.loadlevel() dont work

seems like Application.LoadLevel is obsolote and we should switch to SceneManager.Loadscene but there i cant make it to use same LevelManage to go back to start button when i am trying to complete the NumberWizardUI

any ideas? at the moment i am pointing to Game how do i do so it works correctly?

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

public class LevelManager : MonoBehaviour {

 public void LoadLevel(string name){
		Debug.Log("level load requested for: "+name);

public void QuitRequest(string name){
		Debug.Log("I want to quit"+name);


with that should it work in the newest version from Unity


in the next Course I used your code with

using UnityEngine.SceneManagement;

if (maxGuessesAllowed <= 0) { SceneManager.LoadScene(“Win”); }

and its works too

1 Like

Thanks for the heads up! I’m sure this will solve a lot of headaches when I start with Unity 5!


It seems that there’s two different ways for 5.x users to go about that; they both behave fine in Unity itself but one runs into build problems.

I first tried using

using UnityEditor.SceneManagement;
. . .

and things behaved nicely in the editor. When I went to try to compile it to check out the Application.Quit functionality, Unity got upset at me because it couldn’t see UnityEditor for some reason.

I changed the lines in the script to Ashrag’s suggestions of

using UnityEngine.SceneManagement;
. . .

The editor was still happy with this and it compiled and executed properly.

Just wondering - compiling issues aside, is there a reason I should be using one over the other?

Privacy & Terms