Application.loadedLevelName obsolete?
So, Application.loadedLevelName seems to be obsolete, but I can't find the "replacement" function/variable for it? :/
Answer by voxatrophia · Feb 14, 2016 at 09:22 PM
As of 5.3, there is a SceneManagement namespace that has a Scene struct and SceneManager class.
The specific replacement you are looking for is SceneManager.GetActiveScene().name
.
GetActiveScene will return the current scene, which has the variables name, buildIndex, etc.
You need to be sure you include the using UnityEngine.SceneManagement
namespace too.
Perfect, just what I was looking for! Thanks a ton! :D
Answer by harishashmi · Dec 13, 2017 at 01:25 PM
I know it's old query but i wanted to add the answer. SceneManager.LoadScene(SceneManager.GetActiveScene().name) above mentioned line of code is return Level Name . in order to know about the loadedLevel number use. SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex).
Answer by Strangerweather · Feb 14, 2016 at 04:16 PM
All details are here:
http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html
Good luck!:)
What if i need it to be a string value? I'm trying to use it like this :
Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene());
Just doing ".ToString" after doesn't give the right output. :/
Answer by EisToad · Feb 14, 2016 at 05:58 PM
UnityEngine.SceneManagement.SceneManager.LoadScene ("SceneName"); Here you go
Have fun
I'm not looking to load a scene, I want to know the name of the currently loaded one! :P
Your answer
Follow this Question
Related Questions
Spawn added objects into a circle 1 Answer
how to do on single click fire and on drag appears the joystick and get the input from joystick 0 Answers
Movement Unit (RTS) 0 Answers
Car from Unity's standard assets giving me of null reference errors 0 Answers
How do I resolve, get_isActiveAndEnabled can only be called from the main thread error 1 Answer