Hi. I am making an online FPS game and something is wrong. I’m not getting any errors but my GUI in the Lobby is not working. Here is the code:
#pragma strict
var Players : GameObject[];
var LevelsLoaded : int = 0;
var CurMap : String = "SmallTown";
var CurGameMode : String = "TDM";
var SMap : boolean = false;
var SMode : boolean = false;
var StartTime : int = 5;
var StartingMatch : boolean = false;
function Awake ()
{
networkView.group = 1;
}
function onGUI ()
{
GUI.Label(Rect(10, 10, 90, 30),"LOBBY");
if(GUI.Button(Rect(10, 40, 90, 30), "Start Match"))
{
StartMatch();
}
if(GUI.Button(Rect(10, 90, 90, 30), "Select Map"))
{
SMap = true;
}
if(SMap == true)
{
GUI.Box(Rect(120, 0, 100, Screen.height), "Maps");
if(GUI.Button(Rect(125, 20, 90, 25), "Small Town"))
{
CurMap = "SmallTown";
SMap = false;
}
}
if(GUI.Button(Rect(10, 125, 90, 30),"Select Mode"))
{
SMode = true;
}
if(SMode == true)
{
GUI.Box(Rect(120, 0, 100, Screen.height), "GameModes");
if(GUI.Button(Rect(125, 20, 90, 25),"TeamDeathMatch"))
{
CurGameMode = "TDM";
SMode = false;
}
}
if(StartingMatch == true)
{
GUI.Label(Rect(Screen.width-150,Screen.height-25,150,25),"Match Starts In: " + StartTime);
}
}
function StartMatch ()
{
StartingMatch = true;;
yield WaitForSeconds(1);
StartTime --;
yield WaitForSeconds(1);
StartTime --;
yield WaitForSeconds(1);
StartTime --;
yield WaitForSeconds(1);
StartTime --;
yield WaitForSeconds(1);
StartTime --;
Network.RemoveRPCsInGroup(0);
Network.RemoveRPCsInGroup(1);
networkView.RPC("StartGame", RPCMode.AllBuffered, CurMap, LevelsLoaded);
}
@RPC
function StartGame ()
{
Debug.Log("Load: " + CurMap);
}
It is attached to an Empty -by the way- and I am very confused why the GUI does not show up!!! Please help.