- Home /
Main Menu Script Issues
I'm coding a game based off the book Maze Runner, and so I created 2 levels named MazeRunner and Main Menu. The MazeRunner Level is working smoothly, but the main menu is having issues with the script. It's saying MissingMethodException:UnityEngine.Application.LoadLevelName. Can anyone help me? This is for a project that is due this Friday! Here is my script
var quit=false;
function OnMouseEnter() {
renderer.material.color = Color.green; //Change Color to green!
}
function OnMouseExit() {
renderer.material.color = Color.white; //Change Color to white!
}
function OnMouseUp() {
if (quit == true)
{
Application.Quit(); //If you click on quit aplication quits.
}
else
{
Application.LoadLevelName ("Maze Runner"); //If you click on other button it loads game!
}
}
function Update() { if (Input.GetKey(KeyCode.Escape)) //If you press (escape) game force closes! { Application.Quit(); }
}
Answer by RudyTheDev · Dec 07, 2014 at 09:55 PM
What exactly is Application.LoadLevelName
in your code? There is no such variable/method in Unity's Application
class. Closest I see is Application.loadedLevelName.
To actually load a different scene, it's Application.LoadLevel (and a couple similar ones).
Thanks for pointing that out, I changed that variable, but I'm having another issue. It told me Level '$$anonymous$$azeRunner' (-1) couldn't be loaded because it has not been added to the build setting. So then I made a build (File->Build Settings) but I'm still getting this error whenever I try to play the game. Any chance of you helping me with this one? Thanks.
Clearly your scene is not called "$$anonymous$$azeRunner" then. I see you use "$$anonymous$$aze Runner" above.
I changed it but that still didn't fix it ;/ I keep getting the build setting error
Haha XD I noticed a very obvious error and fixed it. It's working perfectly now thanks for the help!
Your answer
Follow this Question
Related Questions
2D bullet script errors. 1 Answer
[Closed] MainMenu Script error 2 Answers
Scripting error #2! 2 Answers
Error... that I don't understand. 3 Answers
Error UCE0001 ";"Expected 2 Answers