Hi! I have request,can you please edit my code.I am making simple soundboard,but i wan’t to make code work on audio click,not on mouse enter.Like,when you click on text,changes red and starts to play audio,when audio ends,text changes to color white again.
#pragma strict
var isQuitButton = false;
var sound : AudioClip;
function OnMouseEnter()
{
renderer.material.color = Color.red;
audio.PlayOneShot(sound);
}
function OnMouseExit()
{
renderer.material.color = Color.white;
audio.Stop();
}
Can you please someone edit code,to make it like,when you click audio 2x it plays at the same time(multisound of one audio)Can you please fix it,i won’t these multisounds.And i want when i click somewhere else(except box collider) audio stops sounding.I hope you understood my bad english
#pragma strict
var isQuitButton = false;
var sound : AudioClip;
function OnMouseDown()
{
renderer.material.color = Color.red;
audio.PlayOneShot(sound);
waitForAudio(audio.clip.length);
}
function waitForAudio( time:float){
yield WaitForSeconds(time);
//change color back
renderer.material.color = Color.white;
}