I have a simple button script for a two state button, but I'm having trouble trying to figure out how to make the sound stop looping when I press the button again. Here is what my script looks like.
//var levelToLoad : String;
var mouseUpTexture : Texture2D;
var mouseDownTexture : Texture2D;
var beep : AudioClip;
var SurveillanceSoundFX : AudioClip;
function OnMouseDown(){
guiTexture.texture = mouseDownTexture;
audio.PlayOneShot(beep);
audio.loop = true; audio.clip = SurveillanceSoundFX; audio.Play();
}
function OnMouseUp(){
guiTexture.texture = mouseUpTexture;
yield new WaitForSeconds(0.3);
//Do Something
}
↧