O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required