Hi, I have this script:
using UnityEngine;
using System.Collections;
public class MenuManager : MonoBehaviour
{
public string CurrentMenu;
public string MatchName = "";
public string MatchPassword = "";
public int MatchMaxPlayers = 32;
private Vector2 ScrollLobby = Vector2.zero;
void Start()
{
CurrentMenu = "Main";
MatchName = "Survival " + Random.Range(0, 5000);
}
void OnGUI()
{
if (CurrentMenu == "Main")
Menu_Main();
if (CurrentMenu == "Lobby")
Menu_Lobby();
if (CurrentMenu == "Host")
Menu_HostGame();
}
public void NavigateTo(string nextmenu)
{
CurrentMenu = nextmenu;
}
public void Menu_Main()
{
if (GUI.Button(new Rect(10, 10, 200, 50), "Host Game"))
{
NavigateTo("Host");
}
if (GUI.Button(new Rect(10, 10, 200, 50), "Refresh"))
{
MasterServer.RequestHostList("");
}
GUI.Label(new Rect(220, 10, 130, 30), "Player Name");
MultiplayerManager.instace.PlayerName = GUI.TextField(new Rect(350, 10, 150, 30), MultiplayerManager.instace.PlayerName);
if (GUI.Button(new Rect(510, 10, 100, 30), "Save Name"))
{
PlayerPrefs.GetString("PlayerName", MultiplayerManager.instace.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"))
{
}
GUILayout.EndHorizontal();
}
GUILayout.EndArea();
}
public 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"))
{
MultiplayerManager.instace.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;
}
public void Menu_Lobby()
{
ScrollLobby = GUILayout.BeginScrollView(ScrollLobby, GUILayout.MaxWidth(200));
foreach(MPPlayer pl in MultiplayerManager.instace.PlayerList)
{
GUILayout.Box(pl.PlayerName);
}
GUILayout.EndScrollView();
}
void OnServerInitialized()
{
NavigateTo("Lobby");
}
void OnConnectedToServer()
{
NavigateTo("Lobby");
}
}
It game me 2 errors:
error CS1012: Too many characters in character literal â line 89, 96
error CS1525: Unexpected symbol `â â line 89, 98
The debugger says no errors but in the engine i have these errors.
Script is wrote in C#
Sorry for my bad English ![]()