Hi guys, i have created this script it basically plays a song when clicked on and that's all good but i would like to ask your help with something. what i want to do is if i click on my GUI button while the song is playing i want it to stop the track. This is if i click on the same GUI if the music is playing.
Here is the script :
var MyAudioTrack1Naruto : AudioClip;
//var MyAudioTrack2Naruto : AudioClip;
//var MyAudioTrack3Naruto : AudioClip;
//var MyAudioTrack4Naruto : AudioClip;
//var MyAudioTrack5Naruto : AudioClip;
function OnGUI () {
//Make the first button
if(GUI.Button (Rect(10, 20,105,20), "Play Track 1 (Naruto Enter) ")){
if (!audio.isPlaying){
audio.Stop(); //if something else is playing stop it and then play track
audio.clip = MyAudioTrack1Naruto;
audio.PlayOneShot(MyAudioTrack1Naruto);
}
}
}
Oh and thanks in advance :)