Hello!
I was trying to make main menu for my game. I wanted to have sound when clicking “start game” button, but when I use yield WaitForSeconds (3); my sound is playing after those 3 seconds, and it plays for only about half a second and then the level loads. I want this sound playing immediately after pressing the button. I was wondering if anybody can help me. Here’s my main menu script:
var isQuit=false;
var hoverSound : AudioClip;
var clickSound : AudioClip;
var levelNumber : int;
function OnMouseEnter(){
GetComponent.().material.color=Color.red;
GetComponent.().PlayOneShot(hoverSound);
}
function OnMouseExit(){
GetComponent.().material.color=Color.white;
}
function OnMouseUp(){
if (isQuit==true) {
Application.Quit();
}
else{
yield WaitForSeconds (3)
Application.LoadLevel(levelNumber);
GetComponent.().PlayOneShot(clickSound);
}
}
function Update(){
if (Input.GetKey(KeyCode.Escape)) {
Application.Quit();
}
}
Sorry for my bad english ![]()