Game Development Reference
In-Depth Information
void OnGUI()
{
if(showStats)
{
statsRect = GUI.Window(0, statsRect,
StatsGUI, "Stats");
}
}
In the OnGUI function, we check the showStats Boolean variable to see whether
or not the stats menu will be seen on the screen. You can see that it calls a function
named StatsGUI . This function is what draws everything to the screen; let's add
that function now:
void StatsGUI(int ID)
{
GUILayout.BeginArea(new Rect(15, 25, 400,
400));
GUILayout.BeginVertical();
GUILayout.Label("Level - " + pLevel);
GUILayout.Label("Gold - " + pCurrentGold);
GUILayout.Label("Kills - " + pKills);
GUILayout.Label("Deaths - " + pDeaths);
GUILayout.Label("Kill/Death Ratio - " + pKDR);
GUILayout.Label("Rounds Won - " + pRoundsWon);
GUILayout.Label("Rounds Loss - " +
pRoundsLost);
GUILayout.Label("Win/Loss Ratio - " + pWLR);
GUILayout.Label("Time Played (in minutes) - "
+ (pTimePlayed / 60.00f));
GUILayout.EndVertical();
GUILayout.EndArea();
}
Search WWH ::




Custom Search