- Home /
Application.LoadLevel obsolete but SceneManager.LoadScene Doesn't work
So this is probably a stupid question but i'm stumped. So i tried to run this using Application.LoadLevel to load this but unity tell me that using that method is obsolete and said to use scenemanager.loadscene instead however i get the error. CS0103 The name 'SceneManager' does not exist in the current context
i really and stumped and dont know what to do...
using UnityEngine;
using System.Collections;
public class ClickToChange : MonoBehaviour {
void OnMouseDown()
{
SceneManager.LoadScene("Menu_Level");
}
}
Do you have the scene manager imported? Does scene manager need to be instantiated before being run?
Thank you for asking this question, i had the exact same problem till i came here :)
Answer by tanoshimi · Dec 16, 2015 at 01:29 PM
You're missing:
using UnityEngine.SceneManagement;
at the top of your class.
Or this? ;)
Scene$$anonymous$$anagement.Scene$$anonymous$$anager.LoadScene("$$anonymous$$enu_Level");
Is there actually anything wrong with Applicaion.LoadLevel and Application.LoadScene? It seems to work fine for me but Unity keeps telling me it isn't.
Application.LoadLevel is obsolete and will be removed in future versions.
Unity 5.3 introduced multi-scene handling, and that's what the Scene$$anonymous$$anager class is designed to do. The old Application.LoadLevel still works, but it's deprecated - which means that it's no longer the recommended way to do it, and this is a feature that may stop working in future versions.
Thank you so much. It worked, can't believe that I didn't think of that.
Answer by Boggs · Dec 18, 2015 at 08:20 PM
I remember hearing about the multi-scene feature in a live training course, did not know that update happened. Good to know thanks!
Answer by superdiederik · Dec 22, 2015 at 09:07 AM
Application.LoadLevel is giving me crashes under Unity 5.3.1f1 (64-bit) so I suggest we all move to using the using UnityEngine.SceneManagement a.s.a.p.
Answer by Unity_scat · May 07, 2016 at 05:04 AM
looks like the updated version of Application.LoadLevel (SceneManager.LoadScene) only works in c#
no errors but it still doesn't work... Unity needs to fix this
The scene manager works fine in Js too! You only need to write the script like this:
Scene$$anonymous$$anagement.Scene$$anonymous$$anager.LoadScene("SceneName");
With the "Scene$$anonymous$$anagement." before the usual C# format.
I tried LU$$anonymous$$S123456's simple one line call: Scene$$anonymous$$anagement.Scene$$anonymous$$anager.LoadScene("SceneName"); No imports, declarations...A$$anonymous$$AZING! Thanks LU$$anonymous$$S. I expected an error but it works! So I guess Unity's Scene $$anonymous$$anager is referenced directly from the JS script. Does that apply to other components? Probably. The normal way to do that was:
import UnityEngine.Scene$$anonymous$$anagement; //at the top of the JS script, then to call it: Scene$$anonymous$$anager.LoadScene("SceneName");
Even in C# you have to declare 'using UnityEngine.Scene$$anonymous$$anagement;' I tried the Scene$$anonymous$$anagement.Scene$$anonymous$$anager.LoadScene("SceneName") without any declarations (just the one line) and it worked, that's even better (simpler) than C#'s Scene $$anonymous$$anager access. I am not as familar with java though, mostly C++ and C#, so thanks LU$$anonymous$$S.
Your answer
Follow this Question
Related Questions
Unity Scene not loading. 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Can I build a scene once and have it be importable? 2 Answers
How scene loading works? 1 Answer