|
Sorry if this has been covered elsewhere, I did not see it. Is the Input's Touch position 'inverted' relative to the screen? The reason I ask is that if I do this: where windowRect is set in OnGUI: It will only 'do something' IFF I touch the screen in the 'mirrored' position (up/down aka Y direction). Ex: if my windows is near the top of my screen, it will not detect this containment if I touch near the top (inside the window). But it WILL detect if I touch on the opposite side of the screen (same X, opposite Y). I must have missed something in the docs? Or is it a bug? Update: Is this what GUIUtility.ScreenToGUIPoint is for?
(comments are locked)
|
|
Technically, it is not inverted. Touch position and mouse position are returned by the Input class in screenspace coordinates, whereas OnGUI uses GUI space coordinates. In screenspace, (0, 0) is on the bottom-left corner of the screen while it is on the top-left corner of the screen in GUI space. My puzzlement is that this same check for Mouse coordinates seems to be ok. At least, I haven't noticed any problems. But Touch coordinates seem backward. I tried copying the windowRect and setting y to Screen.height-windowRect.y, but that didn't help. I'm not sure if these GUIUtility funcs will help, nor which one (ScreenToGUI or GUIToScreen) would be better. Trying them now...
Jun 23 '11 at 12:46 AM
DaveA
To convert screenspace coordinates to GUI space coordinates:
Jun 23 '11 at 12:59 AM
Dreamblur
Yep, that's pretty much I just came up with too. Thanks. I think the difference is (and btw the GUIUtility funcs didn't work) because I was doing this in Update and not OnGUI.
Jun 23 '11 at 01:03 AM
DaveA
(comments are locked)
|

Yoda, I can't believe you've been stumped by this same invertedness !
We were all new once....