-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenuBtns.cs
50 lines (43 loc) · 1.2 KB
/
MainMenuBtns.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class MainMenuBtns : MonoBehaviour {
// Manages the functionality of all buttons in use within the main menu.
public string levelToLoad;
public Texture2D normalTexture;
public Texture2D rollOverTexture;
public AudioClip beep;
public bool quitButton = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// changes the GUI texture in use upon roll over
void OnMouseEnter(){
guiTexture.texture = rollOverTexture;
}
// changes the GUI testure in use when levaing the area of the element
void OnMouseExit(){
guiTexture.texture = normalTexture;
}
// co-routine handling actions when buttons are pressed
IEnumerator OnMouseUp(){
// plays a sound when button is pressed
audio.PlayOneShot(beep);
// pauses function
yield return new WaitForSeconds(0.35f);
// logic determining which button was pressed
if(quitButton){
// quits game
Application.Quit();
// added to test quit within Unity without having to build
Debug.Log("Quit Button pressed.");
}
else{
// loads level
Application.LoadLevel(levelToLoad);
}
}
}