Application.LoadLevel(Application.loadedLevel) Obsolete

OK, so here is the deal.

Application.LoadLevel (Application.loadedLevel);

nityEngine.Application.loadedLevel’ is obsolete: `Use SceneManager to determine what scenes have been loaded.

Tried that, it does not work.,

Tried to set it instead to SceneManager.LoadScene(index);

It does not work.

I go to the webpage here to find an alternative option. There isn’t one listed.

I added

using UnityEngine.SceneManagement;

as the editors suggested.

It did not work.

So what will?

Even the people who have been using this Application.loadlevel are having problems finding a work around especially when setting up health bars UI interfaces and calling the current scene.

If anyone has an actual work around, would really appreciate it listed in the scripting page.

Currently in Unity 5.3. that fixed a lot of other issues. But now this? -_-, common already.

Do you have a custom script already named SceneManager? If that’s the case that may explain why it’s not accessing UnityEngine.SceneManagement.SceneManager, because even if you have ‘using UnityEngine.SceneManagement’ Unity will still look for your custom script instead.

Maybe you don’t, but this was definitely the issue for me and others I came across.

Try typing out the entire address to test it instead in your code.

Here’s an example that I did which worked for me.

	public void RestartLevel()
		Debug.Log("restart function called");

//		Application.LoadLevel(Application.loadedLevel);			//old function

If you use this code you don’t even need to import the SceneManagment address… while it is obviously not preferable call SceneManager using its full address every time, this will ultimately let you know if you’re able to properly access Unity’s new SceneManager.







Apenas basta usar isso em seu código

using UnityEngine.SceneManagement;

e utilizar em sua função isso


SceneManager.LoadScene(“SceneName”, LoadSceneMode.Additive);

the above code is working for me fine … Application.Loadscene has been deprecated from unity newer versions.
See the detail of sceneManagement from below link.