- Home /
Unity CS1519 Error
Argh i know its a newbie question but i'm getting an error
Assets/MenuManager.cs(12,12): error CS1519: Unexpected symbol 'void' in class, struct, or interface member declaration
can someone help? here's the code if you need it.. using UnityEngine; using System.Collections; public class MenuManager : MonoBehaviour { public string CurrentMenu; public string MatchName = ""; public string MatchPassword = ""; public int MatchMaxPlayers = 32, void Start() { CurrentMenu = "Main"; } void OnGUI() { if (CurrentMenu == "Main") Menu_Main(); if (CurrentMenu == "Lobby") Menu_Lobby(); if (CurrentMenu == "Host") Menu_HostGame(); } public void NavigateTo(string nextmenu) { CurrentMenu = nextmenu; } private void Menu_Main() { if (GUI.Button (new Rect (10, 10, 200, 50), "Host Game")) { NavigateTo("Host"); } } private void Menu_HostGame() { //Buttons Host Game if (GUI.Button (new Rect (10, 10, 200, 50), "Back")) { NavigateTo("Main"); } if (GUI.Button (new Rect (10, 60, 200, 50), "Start Server")) { } GUI.Label(new Rect (220, 10, 130, 30), "Match Name"); MatchName = GUI.TextField(new Rect(400, 10, 200, 30), MatchName); GUI.Label(new Rect (220, 50, 130, 30), "Match Password"); MatchPassword = GUI.PasswordField(new Rect(400, 50, 200, 30), MatchPassword, '*'); GUI.Label(new Rect (220, 90, 130, 30), "Match Max Players"); GUI.Label(new Rect (400, 90, 200, 30), MatchMaxPlayers.ToString ()); MatchMaxPlayers = Mathf.Clamp(MatchMaxPlayers, 8, 32); if (GUI.Button(new Rect (425, 90, 25, 30), "+")) MatchMaxPlayers += 2; if (GUI.Button(new Rect(450, 90, 25, 30), "-")) MatchMaxPlayers -= 2; } private void Menu_Lobby() { } }
Answer by GameVortex · Jan 10, 2014 at 09:22 AM
On line three you have put a comma instead of a semicolon. This makes it so it does not recognize the next set of code, therefore the void was unexpected for the compiler.
Change this:
public int MatchMaxPlayers = 32,
To this:
public int MatchMaxPlayers = 32;