Play on Click GUI [ Unity ]
Well i got bored an decided to share a Play on Click GUI Script, Basically what it does is when you click it plays an audio source for a short period of time. You can adjust it to your preference if you like or add on to it. I'am Still learning how to code GUI in unity i will share as many scripts as i can.
Paste Bin Verison
http://pastebin.com/28r0J5JQ
Code:
var model : GameObject;
var track : AudioSource;
function OnGUI () {
//background box
GUI.Box (Rect (10,130,100,90), "Sounds");
//Make first button
if (GUI.Button (Rect(20,160,80,20), "Go")){
audio.clip = track;
audio.loop = false;
audio.Play();
}
//Make second button
if (GUI.Button (Rect(20,190,80,20), "Stop")){
audio.Stop();
}
}
http://pastebin.com/28r0J5JQ
