private void InitiateButtonClickSfx()
{
audio.PlayOneShot(buttonClickSfx);
}
private void OnGUI()
{
if (showGUI == true)
{
this.currentMenuComponent();
}
}
At the very last line it is reading that, that bracket as a Parsing Error. I’m terrible at programming. Below is the full script:
public class OptionsMenu : MonoBehaviour
{
public GUISkin menuSkin;
public AudioClip buttonClickSfx;
private delegate void MenuComponentMethod();
private MenuComponentMethod currentMenuComponent;
private static float volume;
public float gameVolume = 10.0F;
public float masterVolume = 10.0F;
public float musicVolume = 10.0F;
public bool showGUI = false;
void Start()
{
this.currentMenuComponent = MainMenuComponent;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (showGUI == false)
{
showGUI = true;
return;
}
if (showGUI == true)
{
showGUI = false;
this.currentMenuComponent = MainMenuComponent;
return;
}
}
}
public void MainMenuComponent()
{
GUI.skin = this.menuSkin;
GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));
{
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 250, 200, 50), "Settings"))
{
InitiateButtonClickSfx();
this.currentMenuComponent = SettingsComponent;
}
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 195, 200, 50), "Controls"))
{
InitiateButtonClickSfx();
this.currentMenuComponent = ControlsComponent;
}
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 140, 200, 50), "Back"))
{
InitiateButtonClickSfx();
showGUI = false;
return;
}
if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 85, 200, 50), "Main Menu"))
{
InitiateButtonClickSfx();
//Application.LoadLevel("levelnamehere");
}
}
GUI.EndGroup();
}
public void SettingsComponent()
{
GUI.skin = this.menuSkin;
GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));
{
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 600), "");
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 300, 800, 25), "Settings Menu");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 275, 400, 25), "Volume Settings");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 250, 400, 25), "Master Volume");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 200, 400, 25), "Game Volume");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 150, 400, 25), "Music Volume");
AudioListener.volume = masterVolume / 10;
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 225, 400, 25), "");
masterVolume = GUI.HorizontalSlider(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 220, 400, 25), masterVolume, 0.0f, 10.0f);
AudioListener.volume = gameVolume / 10;
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 175, 400, 25), "");
gameVolume = GUI.HorizontalSlider(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 170, 400, 25), gameVolume, 0.0f, 10.0f);
AudioListener.volume = musicVolume / 10;
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 125, 400, 25), "");
musicVolume = GUI.HorizontalSlider(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 120, 400, 25), musicVolume, 0.0f, 10.0f);
/* Overall Graphical Settings */
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 275, 400, 25), "Overall Graphical Settings");
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 250, 400, 25), "Low"))
{
InitiateButtonClickSfx();
QualitySettings.SetQualityLevel(0);
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 225, 400, 25), "Medium"))
{
InitiateButtonClickSfx();
QualitySettings.SetQualityLevel(1);
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 200, 400, 25), "High"))
{
InitiateButtonClickSfx();
QualitySettings.SetQualityLevel(2);
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 175, 400, 25), "Ultra"))
{
InitiateButtonClickSfx();
QualitySettings.SetQualityLevel(3);
}
/* Antialiasing Filter Settings */
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 150, 400, 25), "Antialiasing Filter Settings");
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 125, 400, 25), "None"))
{
InitiateButtonClickSfx();
QualitySettings.antiAliasing = 0;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 100, 400, 25), "X2"))
{
InitiateButtonClickSfx();
QualitySettings.antiAliasing = 2;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 75, 400, 25), "X4"))
{
InitiateButtonClickSfx();
QualitySettings.antiAliasing = 4;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 50, 400, 25), "X8"))
{
InitiateButtonClickSfx();
QualitySettings.antiAliasing = 8;
}
/* Anisotropic Filter Settings */
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 25, 400, 25), "Anisotropic Filter Settings");
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 0, 400, 25), "Disabled"))
{
InitiateButtonClickSfx();
QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -25, 400, 25), "Enabled"))
{
InitiateButtonClickSfx();
QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -50, 400, 25), "Force Enabled"))
{
InitiateButtonClickSfx();
QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable;
}
/* Texture Quality Settings */
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -75, 400, 25), "Texture Quality Settings");
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -100, 400, 25), "Low"))
{
InitiateButtonClickSfx();
QualitySettings.masterTextureLimit = 2;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -125, 400, 25), "Medium"))
{
InitiateButtonClickSfx();
QualitySettings.masterTextureLimit = 1;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -150, 400, 25), "High"))
{
InitiateButtonClickSfx();
QualitySettings.masterTextureLimit = 0;
}
/* vSync Settings */
GUI.Box(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -175, 400, 25), "vSync");
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -200, 400, 25), "Off"))
{
InitiateButtonClickSfx();
QualitySettings.vSyncCount = 0;
}
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -225, 400, 25), "On"))
{
InitiateButtonClickSfx();
QualitySettings.vSyncCount = 1;
}
/* Shadow Settings */
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 100, 400, 25), "Overall Shadow Settings");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 75, 400, 25), "Shadow Drawing Distance");
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 50, 400, 25), "1"))
{
InitiateButtonClickSfx();
QualitySettings.shadowDistance = 1;
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 25, 400, 25), "50"))
{
InitiateButtonClickSfx();
QualitySettings.shadowDistance = 50;
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - 0, 400, 25), "100"))
{
InitiateButtonClickSfx();
QualitySettings.shadowDistance = 100;
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -25, 400, 25), "200"))
{
InitiateButtonClickSfx();
QualitySettings.shadowDistance = 200;
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -50, 400, 25), "300"))
{
InitiateButtonClickSfx();
QualitySettings.shadowDistance = 300;
}
/* Vegetation Settings */
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -75, 400, 25), "Vegetation Settings");
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -100, 400, 25), "Soft Vegetation");
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -125, 400, 25), "On"))
{
InitiateButtonClickSfx();
QualitySettings.softVegetation = true;
}
if (GUI.Button(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -150, 400, 25), "Off"))
{
InitiateButtonClickSfx();
QualitySettings.softVegetation = false;
}
/* Machine information */
GUI.Box(new Rect(Screen.width / 2 - 0, Screen.height / 2 - -175, 400, 75),
"Machine Information:
GPU: " + SystemInfo.graphicsDeviceName +
"
GPU Memory: " + SystemInfo.graphicsMemorySize + “MB” +
"
CPU: " + SystemInfo.processorType +
"
RAM: " + SystemInfo.systemMemorySize + “MB”);
if (GUI.Button(new Rect(Screen.width / 2 - 400, Screen.height / 2 - -250, 800, 50), "Back"))
{
InitiateButtonClickSfx();
this.currentMenuComponent = MainMenuComponent;
}
}
GUI.EndGroup();
}
private void InitiateButtonClickSfx()
{
audio.PlayOneShot(buttonClickSfx);
}
private void OnGUI()
{
if (showGUI == true)
{
this.currentMenuComponent();
}
}