i tried to make so when i press the button it plays a random sound. When I keep on clicking on the button I want the first sound plays to the end and no other sounds start to play until the first sound is over.
var cake : AudioClip[];
function OnGUI()
{
if (GUI.Button( Rect( 5, 50 , 310, 435), "Play Sound"))
{
if (!audio.isPlaying)
{
audio.PlayOneShot(cake[Random.value * cake.length]);
}
else
{
}
}
}