Graphics Reference
In-Depth Information
ConfirmExitGame();
}
// End the group we started above. This is very
// important to remember!
GUI.EndGroup ();
break;
To make sure that our players don't accidentally exit the game, this script provides a
separate menu screen to show a simple exit confirmation with “yes” and “no” buttons. The
ConfirmExitGame() function sets whichMenu to 2, used by the switch statement to show
the confirm screen.
GUI.EndGroup() ends the UI group—important to remember to include this call;
otherwise, any additional UI rendered after this line will be within this group's coordinate
system and part of this group.
When the variable whichMenu is set to 1, our OnGUI function contains a code to
render a simple options menu. The base menu system allows players to change audio and
graphics. The menu also uses a back button to go back to the main menu:
case 1:
// Options menu
GUI.BeginGroup (new Rect (native_width / 2 - 150,
native_height / 2 - 250, 500, 500));
// Are you sure you want to exit?
GUI.Label(new Rect(0, 50, 300, 50), "OPTIONS",
"textarea");
if(GUI.Button(new Rect(0, 250, 300, 40 ),"AUDIO OPTIONS"))
{
ShowAudioOptionsMenu();
}
if(GUI.Button(new Rect(0, 300, 300, 40),"GRAPHICS
OPTIONS"))
{
ShowGraphicsOptionsMenu();
}
if(GUI.Button(new Rect(0, 400, 300, 40),"BACK TO
MAIN MENU"))
{
GoMainMenu();
}
GUI.EndGroup ();
ShowAudioOptionsMenu(), ShowGraphicsOptionsMenu() and GoMainMenu() are
functions that simply set the variable whichMenu for the different menu screens.
The next menu case is a simple confirm-exit screen, a text label with two buttons that
call either the ExitGame() function or the GoMainMenu() function:
Search WWH ::




Custom Search