hi
I wrote this code:
public class MenuManager : MonoBehaviour
{
public string CurrentMenu;
public string matchName = "";
public string matchPassword = "";
public int matchMaxplayers = 32;
public HostData match;
private Vector2 ScrollLobby = Vector2.zero;
void Start()
{
CurrentMenu = "Main";
matchName = "PixelWarz" + Random.Range(0,5000);
}
void OnGUI()
{
if (CurrentMenu == "Main")
Main_Menu();
if (CurrentMenu == "Lobby")
Main_Lobby();
if (CurrentMenu == "Host")
Menu_Gamehost();
}
public void NavigateTo(string nextMenu)
{
CurrentMenu = nextMenu;
}
private void Main_Menu()
{
if(GUI.Button(new Rect(10,10,200,50),"Host Game"))
{
NavigateTo("Host");
}
if(GUI.Button(new Rect(10,70,200,50),"Refresh"))
{
MasterServer.RequestHostList("DeathMatch");
}
GUI.Label(new Rect(220,10,130,30),"Player Name:");
MultiplayerManager.instance.playerName = GUI.TextField(new Rect(350,10,150,30),MultiplayerManager.instance.playerName);
if(GUI.Button(new Rect(510,10,100,30),"Save Name"))
{
PlayerPrefs.SetString("Player Name",MultiplayerManager.instance.playerName);
}
GUILayout.BeginArea(new Rect(Screen.width - 400,0,400,Screen.height),"Server List","Box");
foreach(HostData match in MasterServer.PollHostList);
{
GUILayout.BeginHorizontal("Box");
GUILayout.Label(match.gameName);
if(GUILayout.Button("Connect"))
Network.Connect(match);
GUILayout.EndHorizontal();
}
GUILayout.EndArea();
}
private void Menu_Gamehost()
{
if(GUI.Button(new Rect(10,10,200,50),"Back"))
{
NavigateTo("Main");
}
if(GUI.Button(new Rect(10,60,200,50),"Start Server"))
{
MultiplayerManager.instance.startServer(matchName,matchPassword,matchMaxplayers);
}
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 Main_Lobby()
{
ScrollLobby = GUILayout.BeginScrollView(ScrollLobby,GUILayout.MaxWidth(200));
foreach(mpPlayer pl in MultiplayerManager.instance.playerList)
{
GUILayout.Box(pl.playerName);
}
GUILayout.EndScrollView();
}
void OnServerInitialized()
{
NavigateTo("Lobby");
}
void OnConnectedToServer()
{
NavigateTo("Lobby");
}
}
and the unity say:Assets/Scripts/MenuManager.cs(57,56): error CS0446: Foreach statement cannot operate on a `method group’
and i dont know what the problem
someone can tell me what the problem is?
thx for all the helpers