- Home /
Question by
pHOENIXENT · Jun 12, 2013 at 05:03 PM ·
guiiostouchplay
How to play sound on GUI touch IOS
I was wondering, how can i play a sound when I touch a GUI texture, but in IOS. for instance, imagine you have a gui texture, and when you press it a sound comes from an audio source near you, how can i do that? Thanks!
Comment
Answer by Graham-Dunnett · Jun 13, 2013 at 07:53 PM
Figure out if the user has touched the screen:
http://docs.unity3d.com/Documentation/ScriptReference/Input.GetTouch.html
If the user has made a touch, figure out if they have touched on the GUITexture:
http://docs.unity3d.com/Documentation/ScriptReference/GUIElement.HitTest.html
If the GUITexure has bee touched, play a sound:
http://docs.unity3d.com/Documentation/ScriptReference/AudioSource-clip.html
could you please put the code of how would you implement it.