Here is my code Please help thank you
using UnityEngine;
using System.Collections;
public class MenuRaycast : MonoBehaviour {
private bool inOptionsMenu = false;
private bool showCredits = false;
private Rect windowRect;
public string CREDITS_TEXT = "Text"
void OnGUI()
{
windowRect = new Rect(Screen.width * 0.3f, Screen.height * 0.3f, Screen.width * 0.4f, Screen.height * 0.4f);
if (inOptionsMenu)
windowRect = GUILayout.Window(0, windowRect, GUIDoOptionsMenu, "Options");
else if (showCredits)
windowRect = GUILayout.Window(0, windowRect, GUIDoCredits, "Credits");
}
void GUIDoOptionsMenu(int id)
{
GUILayout.BeginHorizontal(); // Graphics level
GUILayout.Label("Graphics Level:");
if (GUILayout.Button("Fast"))
QualitySettings.SetQualityLevel(0, true);
else if (GUILayout.Button("Normal"))
QualitySettings.SetQualityLevel(3, true);
else if (GUILayout.Button("High"))
QualitySettings.SetQualityLevel(5, true);
GUILayout.EndHorizontal(); // Graphics level
GUILayout.BeginHorizontal(); // Audio
GUILayout.Label("Master volume:");
AudioListener.volume = GUILayout.HorizontalSlider(AudioListener.volume, 0.0f, 1.0f, GUILayout.MinWidth(windowRect.width * 0.5f));
AudioListener.pause = GUILayout.Toggle(AudioListener.pause, "Mute");
GUILayout.EndHorizontal(); // Audio
GUILayout.Space(Screen.height * 0.25f);
if (GUILayout.Button("Done"))
inOptionsMenu = false;
}
void GUIDoCredits(int id)
{
GUILayout.Label(CREDITS_TEXT);
GUILayout.Space(Screen.height * 0.3f);
if (GUILayout.Button("Done"))
showCredits = false;
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
DoMenuRaycast();
}
void DoMenuRaycast()
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 15.0f))
{
switch (hit.collider.name)
{
case "Play Text":
DoPlayButton();
break;
case "Options Text":
DoOptionsButton();
break;
case "Credits Text":
DoCreditsButton();
break;
case "Quit Text":
DoQuitButton();
break;
}
}
}
void DoPlayButton()
{
Application.LoadLevel("Infinite");
}
void DoOptionsButton()
{
showCredits = false;
inOptionsMenu = true;
}
void DoCreditsButton()
{
inOptionsMenu = false;
showCredits = true;
}
void DoQuitButton()
{
Application.Quit();
}
}