- Home /
using OnMouseDown instead of touch functions for touch devices
hi guys im making a game for android and now its button scripting time , but i dont know how write a code for buttons that arent gui , my buttons are simple gameobjects with box collider around , so i used onmousedown function for them , but sometimes during runtime buttons stop from working and then running again , is it because of my function or .... would anybody tell that how can write a touch script from input method of unity for gameobjects , not gui thanks alot , and more
Your question is too wide and might be a forum discussion . If your are able to run and sometimes it stops then you have something working, then please give more details, paste some code you are using so that user can help :)
Answer by hd27 · Jan 21, 2014 at 10:17 AM
You can try casting a ray from the camera position. The hit info that returns from the ray will tell you which object or button you touched.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131010im_/https://answers.unity.com/themes/thub/images/avi.jpg)