Hi i´m trying make a pause menu with gui and i want when the mouse will be on button play sound, i already have sound when clicking but not when i hover mouse on it there is my code: thanks for help
var windowPause:Rect=Rect(1000,1000,1000,1000);
private var showPause:boolean;
var enter : AudioClip;
var press : AudioClip;
var buttonRect : Rect = Rect(110,120,70,30);
function Update () {
if (Input.GetButtonUp ("Pause")) {
if (showPause == true) {
showPause = false;
Time.timeScale = 1;
}
else if (showPause == false){
showPause = true;
Time.timeScale = 0;
}
}
}
function OnGUI () {
if (buttonRect.Contains(Input.mousePosition)) {
audio.PlayOneShot (enter);
}
if (showPause==true){
windowPause= GUI.Window(1, windowPause, DoMyWindowPause, "Pause");
}
}
function DoMyWindowPause () {
if (GUI.Button(Rect(110,80,70,30),"Resume")){
audio.PlayOneShot(press);
showPause = false;
Time.timeScale = 1;
}
if (GUI.Button(buttonRect,"Setting")){
audio.PlayOneShot(press);
}
if (GUI.Button(Rect(110,160,70,30),"Exit")){
audio.PlayOneShot(press);
Application.LoadLevel(0);
Time.timeScale = 1;
}
}