Touch input using OnMouseDown

Greetings,

I was under the impression that you could use OnMouseDown() for single touch events. I don’t need to use Multi-touch, so I was hoping I could just use a mouse click event to simulate touching on iOS.

When I deploy to my iOS device to test, none of my touch inputs are recognized.

Which Unity version are you using?

I’m using the newest 3.x release.

Hi,

I’m not sure if you can use the event ‘OnMouseDown’ but you can definitely just call the functions to poll the mouse status. Here’s an example:

if( Input.GetMouseButtonDown( 0 ) )
bMouseDown0 = true;
if( Input.GetMouseButtonUp( 0 ) )
bMouseDown0 = false;

OnMouse* event support for mobiles is available since Unity 4.0.

I just built my project for ios for the first time and I was surprised to see that my onmousedown functions were working on ios. I was unaware of the change in version 4. I still get a warning in the debug log about how the mouse functions can cause the app to run shower on ios. Is this still an issue or is this just an old warning from before 4? Is there more efficient way to script ios touch input alongside pc mouse input? Thanks!

Well, you can first detect the Application.platform to see if you run iOS or Editor…

From here up to you to set up a if (Input.touchCount == 1) on iOS (basically similar to a press down mouse button…)

Thanks. I was just wondering if casing it out would be more efficient or if using the mouse down functionality on iOS doesn’t actually perform any worse than using touch controls.