Graphics Reference
In-Depth Information
graphicsSliderValue = Mathf.RoundToInt(GUI.
HorizontalSlider (new Rect(0, 200, 300, 50),
graphicsSliderValue, 0, detailLevels));
The back button (which leads out of this menu and back to the options menu) also
makes a call to SaveOptionsPrefs() to store any data updated by the user as this screen
was active:
if(GUI.Button(new Rect(0, 400, 300, 40),"BACK TO
OPTIONS MENU"))
{
SaveOptionsPrefs();
ShowOptionsMenu();
}
Finally, the GUI group is ended as the case breaks out:
GUI.EndGroup ();
break;
A LoadLevel() function uses Application.LoadLevel to load in a new scene:
void LoadLevel( string whichLevel )
{
Application.LoadLevel( whichLevel );
}
The functions GoMainMenu(), ShowOptionsMenu(), ShowAudioOptionsMenu(), and
ShowGraphicsOptionsMenu() set the value of the variable whichMenu so that the case state-
ment from the main OnGUI function will render the required menu:
void GoMainMenu()
{
whichMenu=0;
}
void ShowOptionsMenu()
{
whichMenu=1;
}
void ShowAudioOptionsMenu()
{
whichMenu=3;
}
void ShowGraphicsOptionsMenu()
{
whichMenu=4;
}
PlayerPrefs is used for saving out data we will need later on. In SaveOptionsPrefs(), the
values for sound volume, music volume, and graphics detail level are saved to disk. You may
have noticed some of these PlayerPrefs names from earlier chapters of this topic, where they
were used to set volume levels and graphics settings:
Search WWH ::




Custom Search