Hello,can you please fix my audio bug.I made code,when you click on text with box collider,audio sounds,but when i click it 2x fast same audio plays many times at same moment.Can you please fix it?I need to make,when you click text again,audio stops on second click.First click turns on sound,second turns off.
#pragma strict
var isQuitButton = false;
var sound : AudioClip;
function OnMouseDown()
{
renderer.material.color = Color.red;
audio.PlayOneShot(sound);
waitForAudio(audio.clip.length);
}
function waitForAudio( time:float){
yield WaitForSeconds(time);
//change color back
renderer.material.color = Color.white;
}