- Home /
OnTouch function?
I am trying to port my game over to mobile and many of my scripts use OnMouseUp which just runs when an object is clicked, does anyone know a similar solution for touch? as in OnTouchUp or something?
Answer by kk93 · Feb 07, 2014 at 06:19 PM
There is an asset called Input.Touches on the asset store that handles pretty much every touch gesture you can think of, including OnTouchUp. It is well documented, and support from the developer is great.
I know this is not exactly what you were looking for, but it is worth every penny.
Hope this helped.
Wow that looks great,to bad I have a zero budget. I am going to leave my question unanswered just in case there are more solutions if not I will mark this as the answer. Thanks for the suggestion!
Answer by Ashish Dwivedi · Feb 08, 2014 at 03:22 PM
Use "Input.GetTouch(int index)" and for touch up and touch down use touch phases.
Yes but can you use that to check if you touch an object? that is what On$$anonymous$$ouseDown does so anything that does the same thing is what I am looking for.
Answer by noahdyer · Dec 08, 2014 at 11:03 PM
The question is old, but I'm writing an answer for future viewers. There is no out of the box OnTouch as has been stated, but you can write OnTouch functionality rather simply using a resource like this: http://wiki.unity3d.com/index.php/OnMouseDown
Actually I discovered that (for android atleast) mouse input is emulated automaticialy on the device. I put a mouse controlled game onto an android tablet and it just... worked... lol. But yes, you should probably still read through the documentation of Input and build your own touch system.
In Unity 5 the editor says it would be better not to use on$$anonymous$$ouse_ functions on mobile devices for performance reasons, but I can't see that difference in build (Android)
Your answer
Follow this Question
Related Questions
does getmousebuttondown counts as physicaly clicking (for mobile games)? 1 Answer
Convert Mouse Input to Touch Input 0 Answers
Touch delta distance to be uniform, independent of the pixel density 0 Answers
Input.mousePosition equivalent to first finger touch? 3 Answers
Mobile Touchscreen, vertical screen slice problem,Mobile Input, Horizontal Screen Slicing 1 Answer