Hi guys i just wrote a script which plays a song when the GUI is clicked. The problem that i am having is that when i click the GUI button again it plays the song again and it starts to overlap the song that is playing and it sounds horrible. Now what i want to do is if the song is playing and the GUI button is clicked again i dont want it to play the song again if its playing.
here is the script that i wrote:
var MyAudio : AudioClip;
function OnGUI ()
if (GUI.Button (Rect(10, 20,105,20), "Play Track 1 ( Enter) ")){
audio.PlayOneShot(MyAudio);
}
}
thanks in advance :)