OnMouseDown works fine for iOS

OnMouseDown seems to work fine when I build to my iPhone. Why is there so many examples of people using raycasts and other more complex ways of detecting a tap? Are there any issues with using OnMouseDown for ios that I should be aware of?

I were thinking the exact same. Guess it's a new thing that OnMouseDown etc. works as touch input, but it's really great! :)

2 Answers

2

Have you tried using OnMouseDown with multiple fingers on the touch device?

One possible reason they would be using raycasts is because that can cater for multitouch, using the respective touchpoint’s position as the screen coordinate from which to cast the ray.

OnMouseDown does work nicely, but the system might only cater for the first touchpoint touching down on the touchscreen … However this is probably only a concern on larger devices, not necessarily a smartphone.

The examples exist mostly because for a while Unity didn’t really support OnMouse* events on mobile platforms, so a workaround was needed. It does support it now, although it gives you some warnings about performance.

To my knowledge, no real alternative exists; surely you can do all raycasts yourself, but that looks like a pretty convoluted way to do something that would have performance issues of its own (and probably what Unity is doing internally anyway).

Right now, using OnMouse* away seems to be the right way to go. Just don’t waste it capturing events you don’t need, I suppose.