Graphics Reference
In-Depth Information
4. The value at the right end of the slider. The maximum volume we would need to
set our audio to would be 1. That's why we set the right end of the slider to 1(f).
5. If you wanted to set a GUIStyle, a fifth optional parameter (a string containing the
name of the GUIStyle) may be used here, too.
A little further down in the script, we draw another label and the second horizontal
slider, using the variable audioMusicSliderValue to store its value. Notice that the slider
starts at 0 and ends with a maximum value of 1, the highest amount we would ever need
to which to set the volume property of an AudioSource object:
GUI.Label(new Rect(0, 270, 300, 20), "Music volume:");
audioMusicSliderValue = GUI.HorizontalSlider (new
Rect( 0, 300, 300, 50 ), audioMusicSliderValue,
0.0f, 1f);
Now all that's left to do is provide a method to get back to the options menu and to
end the group. When the button is pressed, we call on two functions: SaveOptionsPrefs()
and ShowOptionsMenu().
if(GUI.Button(new Rect(0, 400, 300, 40),"BACK TO
OPTIONS MENU"))
{
SaveOptionsPrefs();
ShowOptionsMenu();
}
GUI.EndGroup ();
break;
Getting back to the OnGUI menu switch statement, the next menu case is the graph-
ics options menu:
case 4:
First, a group is set up for the UI to be rendered in:
// GRAPHICS OPTIONS
GUI.BeginGroup (new Rect (default_width / 2 - 150,
default_height / 2 - 250, 500, 500));
The labels for the screen are drawn next, with GUI.Label:
GUI.Label(new Rect(0, 50, 300, 50), "GRAPHICS
OPTIONS", "textarea");
GUI.Label(new Rect(0, 170, 300, 20), "Graphics
quality:");
For the graphics detail, the GUI.HorizontalSlider function is used with the variable
graphicsSliderValue:
Search WWH ::




Custom Search