Creating a Graphic Options in game menu

I’m curious to know, how would a person go about creating a GUI window which controls the graphics quality of a game made in Unity3D.

For instance, turning off shadows, Anti-Aliasing, Level of Detail, Texture Quality, screen size, full screen / windowed and so on.

I’m planning on having the option to change quality settings outside of the normal splash screen provided by Unity3D which offers users more control over their graphics settings of the game.

I feel it would be best achieved in C# to allow you to easily store the settings in a *.ini file and load these settings during the loading of the game.

Ok, this is version 1 of my In Game Options menu. It has an example on how to set the volume for Ambient Sound (Specific Audio Source)

All of the settings are saved into a file called, settings.ini, and are read from that file on start up. (Settings are written to the settings.ini file each time a person closes the option menu)

This is something for people to use to get started with. My apologies on how messy it is.

using UnityEngine;
using System.Collections;
using System.Text.RegularExpressions;

public class optionsMenu : MonoBehaviour {
		public static bool showMenu = false;
		private string settings;
	public static float ambianceLevel = 0.0f; //Start muted.
	public static bool fullscreen = false; //default...
	public static string screenres = "1"; //default.
	private string curRes = "1";
	// Use this for initialization
	void Start () {
	settings = System.IO.File.ReadAllText(@"settings.ini"); //Load the settings.
		string[] settingsLines = Regex.Split(settings,"

“);
foreach(string line in settingsLines){
string thisLine = Regex.Split(line,”=");
if(thisLine[0] == “ambiance”){
ambianceLevel = float.Parse(thisLine[1]);
//Debug.Log("Setting ambiance to "+thisLine[1]);
}else if(thisLine[0] == “fullscreen”){
if(thisLine[1] == “True” || thisLine[1] == “true”){
Screen.fullScreen = true;
fullscreen = true;
}else{
Screen.fullScreen = false;
}
}else if(thisLine[0] == “screenresolution”){
switch(thisLine[1]){
case “1”:
Screen.SetResolution(1366,768,fullscreen);
break;

				case "2":
					Screen.SetResolution(1600,900,fullscreen);
					break;
				}
				screenres = thisLine[1];
			}
		}

	}
	
	// Update is called once per frame
	void Update () {
			if(curRes != screenres){
				switch(screenres){
				case "1":
					Screen.SetResolution(1366,768,fullscreen);
				break;
					
				case "2":
					Screen.SetResolution(1600,900,fullscreen);
					break;
				}
			curRes = screenres;
			}
		if(Screen.fullScreen != optionsMenu.fullscreen){
		Screen.fullScreen = optionsMenu.fullscreen;	
		}
	}
	
	public void OnGUI(){
		GUI.depth = 1000;
		if(showMenu == true){
			inGameMenu.showGameMenu = false;
			GUI.Box(new Rect(Screen.width/2-150,Screen.height/2-150,300,300),"");
			GUI.Label(new Rect(Screen.width/2-150,Screen.height/2-150,300,300),"Sound");
			GUI.Label(new Rect(Screen.width/2-145,Screen.height/2-130,300,300),"Ambience");
			GUI.Label (new Rect(Screen.width/2+115,Screen.height/2-130,300,300),((int)(ambianceLevel * 100)).ToString()+"%");
			ambianceLevel = GUI.HorizontalSlider (new Rect (Screen.width/2-80,Screen.height/2-125, 190, 50), ambianceLevel, 0.0f, 1.0f);
			
			//Video;
			GUI.Label(new Rect(Screen.width/2-150,Screen.height/2-100,300,300),"Graphics");
			fullscreen = GUI.Toggle(new Rect(Screen.width/2-150, Screen.height/2-80, 200, 30), fullscreen, "Fullscreen");
			
			if(GUI.Button(new Rect(Screen.width/2-60,Screen.height/2+110,120,30),"Close")){
				showMenu = false;
				inGameMenu.showGameMenu = true;
				saveSettings();
			}
		}
		GUI.depth = 0;
	}
	public static void saveSettings(){
	string output = "ambiance="+((int)(ambianceLevel * 100)).ToString();
		output = output + "

fullscreen=“+fullscreen;
output = output + "
screenresolution=”+screenres;
System.IO.StreamWriter file = new System.IO.StreamWriter(@“settings.ini”);
file.Write(output);
file.Close();
//output = output + "
";
}
}