- Home /
Can you pass a variable to Application.Load level
I am trying to make a generic script that I can use to create portals via a door object then when you walk up to it a gui asks you if you want to travel to the area behind the door, if so press E, anyone know how to do this?
Answer by Jamora · Aug 09, 2013 at 07:18 PM
Application.LoadLevel takes in the level as a parameter. It's overloaded to accept either the name of the scene as a string or the scene number in the build menu.
So all you need to know is either the name of the scene or its number in the build menu, store it in level and then do
Application.LoadLevel(level);
Thanks
EDIT: Converted to comment by @whydoidoit and this added because (unlike Answers) comments must be 10 characters!
Your answer
Follow this Question
Related Questions
Application.Loadlevel("Level Name"); not working on android 2 Answers
Application.LoadLevel(Application.LoadedLevel) causes freeze 0 Answers
Unity 5.3 How to load current level 3 Answers
How to Get Name of Scene Based off Number? 1 Answer
Storing Application.LoadedLevel As a variable not working. 1 Answer