- Home /
Only certain buttons are playing the sound onclick
So I applied sounds on all buttons by:
Creating an Audio Source in the Hierarchy
Adding the sound I want into AudioClip section in Inspector
Went on my UI button into OnClick()
Pressed '+' and dragged my Audio Source object into the box under 'Runtime'
Selected AudioSource.PlayOneShot
Dragged source audio file into the box under AudioSource.PlayOneShot
So the problem here is that some of my buttons are actually playing the sound, and others aren't. I used the exact same method stated above to give sound to each of the buttons.
The buttons are organized as such:
'Play' 'Instructions' 'Quit' -> Menu Scene ('Instructions' doesn't play sound - rest is ok)
'Back' 'Play' -> Instructions Scene (only 'Play' plays sound)
'Play Again' 'Back' -> Game Over Scene (none of these play sound)
If you need any other info or code snippets I'll happily provide thanks !
There's a lot you may need to check. Do all of the buttons have the onclick event? Can they all receive raycast events (No invisible window over the top is blocking them?) Is your audio listener close enough to pick up the sound. Usually audio listener is attached to the camera. $$anonymous$$ake sure the sound falloff is not to small. I'm sure some one else will come by with a better answer.