Game Development Reference
In-Depth Information
}
}
All of the variables that we created are placeholders so that we aren't directly modify-
ing the saved values that are in PlayerPrefs . The last variable, Rect , will be used
to place and size our Options menu. In the Start function, we set the placehold-
ers to some default values and call a LoadAll function. The LoadAll function will
be created later; its purpose is to load our saved data in the placeholders. Finally,
the OnGUI function will run the GUI window that will hold our Options menu.
Creating the GUI
Now, we will create the function that runs the GUI. We will create labels, buttons, ho-
rizontal sliders, and toggle buttons. Add this function to your script:
void OptionsGUI(int gui)
{
GUILayout.BeginArea(new Rect(0, 50, 800,
800));
GUI.Label(new Rect(25, 0, 100, 30), "Quality
Settings");
if(GUI.Button(new Rect(25, 20, 75, 20),
"High"))
GetComponent<Video_Config>().SetResolution(0,
3);
if(GUI.Button(new Rect(100, 20, 75, 20),
"Medium"))
GetComponent<Video_Config>().SetResolution(1,
3);
if(GUI.Button(new Rect(175, 20, 75, 20),
"Low"))
Search WWH ::




Custom Search