- Home /
Help with GUI clicking ???
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 :)
Answer by efge · Feb 23, 2011 at 01:07 PM
You could use:
if (!audio.isPlaying){
audio.clip = MyAudio;
audio.Play();
}
Your answer
Follow this Question
Related Questions
Unity GUI Button Options 0 Answers
Custom GUI Button is Black 1 Answer
Screenshot certain layers so it doesn't show GUI Button on the image?? 0 Answers
GUI.Button click trigger game object 1 Answer