- Home /
Help with menu script!
Hi im developing a menu for my 2d game. But for some reason its not working and it keeps showing me this error...Assets/Menu/Scripts/Menu.cs(16,9): error CS8025: Parsing error. Im not sure why here is my script....any help is welcome.
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour
{
void OnGUI()
{
if(GUI.Button(new Rect(Screen.width/2.5f,Screen.height/3,Screen.width/5,Screen.height/10), "Play Game")
{
Application.LoadLevel(1);
}
if(GUI.Button(new Rect(Screen.width/2.5f,Screen.height/2,Screen.width/5,Screen.height/10), "Exit Game")
{
Application.Quit();
}
}
}
If you are developing a new menu I would strongly suggest upgrading and using the new UI tools. Here is a video tutorial.
Answer by kdubnz · Dec 03, 2014 at 09:36 AM
Which line is Line 16
Looks like you are missing a parenthesis on both the if conditional test.
You may have meant it to look something like this:
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour
{
private void OnGUI()
{
if (GUI.Button(
new Rect(
Screen.width/2.5f,
Screen.height/3,
Screen.width/5,
Screen.height/10),
"Play Game")
)
{
Application.LoadLevel(1);
}
if (GUI.Button(
new Rect(
Screen.width/2.5f,
Screen.height/2,
Screen.width/5,
Screen.height/10),
"Exit Game")
)
{
Application.Quit();
}
}
}
Your answer
Follow this Question
Related Questions
How to get OnTriggerEnter to affect all objects using script 1 Answer
How to send a MotionEvent from Android App to Unity 0 Answers
calling functions help {javascript} 1 Answer
help with an error cant find no solution 1 Answer
All is pink?! 1 Answer