- Home /
I wanna know how to click on something and have it play a audio
I wanna know how to click on something and have it play a audio
Answer by BinaryCore · May 06, 2011 at 01:11 AM
Define something... (A UI element, a 3D object in the game using picking???)
Ok, I'll fill in the blanks: (we'll just go the simple route)
Hook up a sound source Component to the game object your script is attached to. Make sure you have a SoundListener attached (usually to Camera.mainCamera in your scene.)
if you have a GUITexture element in your UI, you can use myElement.HitTest and if that test is true, then call: audio.Play()
You can also call PlayOneShot with an AudioClip as a parameter.
If you are using the Unity GUI. stuff, you can play a sound in response to a GUI.Button being clicked. See the Unity GUI docs for more info. They give good examples.
Your answer
Follow this Question
Related Questions
make audio play on click 1 Answer
Need help on audio trigger. 2 Answers
Play Oneshot Audio On Touch 0 Answers
Audio.Play() not showing up 1 Answer