- Home /
Answer by Trollvahkiin · Oct 24, 2014 at 10:26 PM
Add an event trigger component to a desired UI element and make a new PointerEneter(Hover)/PointerClick(Click) which call a function to play a sound.
$$anonymous$$any thanks I shall try this now! I will also +rep and accept your answer
Just seen this post, I'm using Unity 5 and this still works, thanks!
Excuse me im trying to achieve this sound as well. But i still can't get it to work. Can you ellaborate on the function that enables sound, because nothing im doing seems to work. This is the last function i tried, but it still doesnt work:
public void ButtonHighlighted(int track) { if (track == 1) { audio.PlayOneShot(happy); Debug.Log("Play button highlighted"); } else { audio.PlayOneShot(sad); Debug.Log("Quit Button Highlighted"); } }
Did you correctly reference the audio variable to an audiosource?