Creating the settings menu
The final part of our optimizations will be to add a menu so that the player can access and change the settings we created. Create a new C# script and name it Config_GUI.
Preparing the code
Now, we'll set up our code by adding variables, a start function, and an OnGUI function. Add this code to your script:
float volBG, volSFX, volATM, fov;
bool aa, shadows, sync, optionsGUI, full;
int res;
string settings, audiotype;
public Rect optionsRect = new Rect(100, 100, 500, 500);
void Start()
{
volBG = 0;
volATM = 0.3f;
volSFX = 0.8f;
fov = 90.00f;
aa = true;
fullscreen = true;
shadows = true;
optionsGUI = true;
LoadAll();
}
void OnGUI()
{
if(optionsGUI)
{
optionsRect = GUI.Window(0, optionsRect, OptionsGUI, "Options");
}
}All of the variables that we created are placeholders so that we aren't directly modifying 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...