Help with Main Menu Buttons...
Hi There, I'm fairly new to C# programming in Unity and was wondering if anyone could help me out. I have written a Script of how to do a Start Button and Exit Button. (Simple really, I thought.) I since came across a few typo's but now it's all resolved. Or should be, My only problem is it doesn't work and the console shows, "Assets/MainMenu.cs(50,9): error CS8025: Parsing error". Visual Studio just shows the last line of my script highlighted with,
Severity Code Description Project File Line Suppression State Error CS1513 } expected SandBox Project.CSharp C:\Users\Faith\Desktop\Nathan\PROGRAMMING\Unity\SandBox Project\Assets\MainMenu.cs 50 Active
Here is my code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
public Canvas quitMenu;
public Button startText;
public Button exitText;
// Use this for initialization
void Start()
{
quitMenu = quitMenu.GetComponent<Canvas>();
startText = startText.GetComponent<Button>();
exitText = exitText.GetComponent<Button>();
quitMenu.enabled = true;
}
public void ExitPress()
{
quitMenu.enabled = true;
startText.enabled = false;
exitText.enabled = false;
}
public void NoPress()
{
quitMenu.enabled = false;
startText.enabled = true;
exitText.enabled = true;
}
public void StartLevel()
{
Application.LoadLevel("LevelLoadingScreen");
}
public void exitMenu()
{
if (Input.GetKey("escape"))
Application.Quit();
}
Ps: Thanks in advance...
Answer by jgodfrey · May 21, 2016 at 03:10 PM
Please remember to format your code for the forum after pasting it. To do that, select the pasted code and press the "101010" button in the editor toolbar. Note, I've done that for you here...
The obvious issue with the pasted code is that you're missing the closing brace for the class (the one that matches the open brace on line #6. To fix that, add an additional close brace at the end of the pasted code (assuming that's the end of the class).