- Home /
 
Does onMouseDown convert to a Touch command in iOS or not?
The Unity documentation says that onMouseDown does NOT convert, but this thread says otherwise.
According to this other thread , this might not work due to the image not being a power of 2. I converted and re-imported the image. All without success.
Also, I have tested this, and it doesn't work, but maybe there's a checkbox somewhere I'm not ticking?
Anyone know for sure?
If not, help with using touch with a GUItexture would be much obliged.
Answer by Bunny83 · May 23, 2012 at 07:51 PM
I can't see any post in the thread that states it would work on mobile. Do you refer to nicholas post? He said that they emulated mouse input and generated the function calls manually.
Usually Unity automatically casts a ray each frame to check which object is below the mouse position. On a mobile build this has been disabled for performance reasons. You can still do it manually.
Also note that GetMouseButtonDown is a function, not a callback like OnMouseDown.
Btw your question seems to be flipped ;) I guess you mean if a touch translates to OnMouseDown and the answer is: no.
Thanks Bunny83. I don't assume I need to do a ray cast considering I'm using a GUI which does not have a position in space, only regarding on the screen.
I am using Input.mousePosition along with an Input.GetTouch to detect if there was a touch, and where the touch was. It works if I just make an on$$anonymous$$ouseDown callback with an actual mouse, but not if I use a Update callback with a touch detection. If I detect touch, and then use mousePosition, will it register the position properly?
Oh, and I guess it depends from what side you're looking at. I'm guessing that if I'm compiling for iOS - the on$$anonymous$$ouseDown will convert to touch - but if you're looking at it from an app on the device standpoint then it would be the opposite.
Your answer