- Home /
Menu script not showing up like normal
Hi guys here's my menu script that i've been lloking on for a few hours but dont know why this is happening.I get an error saying unexpected symbol private and my gui.textfield and server list is not showing up on screen.Line 42 and 46.Here's my script.please help.thanks using UnityEngine; using System.Collections;
public class Menu : MonoBehaviour {
private string CurMenu;
public string Name;
public string MatchName;
public int Players;
// Use this for initialization
void Start () {
CurMenu = "Main";
Name = PlayerPrefs.GetString("PlayerName");
}
// Update is called once per frame
void Update () {
}
void ToMenu(string menu){
CurMenu = menu;
}
void OnGUI(){
if (CurMenu == "Main")
Main();
if (CurMenu == "Host")
Host();
if (CurMenu == "Lobby")
Lobby();
if (CurMenu == "List")
MatchList ();
}
private void Main(){
//if (GUI.Button(new Rect (0, 0, 128, 32), "Host A Match")) {
// ToMenu ("Host");
//}
if (GUI.Button (new Rect (0, 0, 128, 32), "Host a match")){
{
ToMenu ("Host");
}
Name = GUI.TextField (new Rect (130, 0, 128, 32), Name);
if (GUI.Button(new Rect (260, 0, 128, 32), "Save")) {
PlayerPrefs.SetString ("PlayerName", Name);
}
if (GUI.Button(new Rect (0, 33, 128, 32), "Server List")){
{
ToMenu ("Host");
}
}
private void Host(){
if(GUI.Button(new Rect(0,0,128,32),"Start")){
NetworkManager.Instance.StartServer(MatchName,Players);
ToMenu("Lobby");
}
if(GUI.Button(new Rect(0,33,128,32),"Back")){
ToMenu("Main");
}
MatchName = GUI.TextField(new Rect(130,0,128,32),MatchName);
GUI.Label(new Rect(260,0,128,32),"Match name");
Players = Mathf.Clamp(Players,0,8);
GUI.Label(new Rect(260,32,128,32),"Max Players");
if (GUI.Button (new Rect (145, 32, 32, 32),"+"))
Players ++;
GUI.Label (new Rect (192, 33, 64, 32), Players.ToString());
if (GUI.Button (new Rect (215, 33, 32, 32),"-"))
Players --;
}
private void Lobby(){
if(GUI.Button(new Rect(Screen.width - 128,Screen.height - 64,128,32),"Start")){
}
if(GUI.Button(new Rect(Screen.width - 128,Screen.height - 32,128,32),"Back")){
ToMenu("Host");
}
}
private void MatchList()
{
if (GUI.Button(new Rect(0,33,128,32), "Refresh"))
{
MasterServer.PollHostList();
}
if (GUI.Button(new Rect(0,33,128,32), "Back"))
{
ToMenu ("Main");
}
GUILayout.BeginArea(new Rect(Screen.width/ 2, 0, Screen.width / 2, Screen.height), "Server List");
foreach (HostData hd in MasterServer.PollHostList())
{
GUILayout.BeginHorizontal();
GUILayout.Label(hd.gameName);
if(GUILayout.Button ("Connect"))
{
Network.Connect(hd);
ToMenu("Lobby");
}
GUILayout.EndHorizontal();
}
GUILayout.EndArea();
}
}
Answer by Kiwasi · Jun 28, 2014 at 10:39 AM
There are two opening brackets to the if clause on line 35.
Sorry but i dont see two openning brace there.But will that help me fix the script?
if (GUI.Button (new Rect (0, 0, 128, 32), "Host a match")) >>> {
{ <<<
To$$anonymous$$enu ("Host");
}
see them now? seems like i can't make them bold.
and there's another (extra) one on line 43!!
Your answer
Follow this Question
Related Questions
GuiButton Going To Next Level 0 Answers
Script working on some objects but not others 1 Answer
Can't get bullet to spawn and move 1 Answer
Pickup script not workimg 0 Answers
Following Script Not Working Properly 0 Answers