Hey Everyone,
Is there an error in the Unity Script Reference?
Input.mousePosition at Unity - Scripting API: Input.mousePosition says:
GUIUtility.ScreenToGUIPoint at Unity - Scripting API: GUIUtility.ScreenToGUIPoint says:
Note: In Unity the screen space y coordinate varies from zero at the top edge of the window to a maximum at the bottom edge of the window. This is different from what you might expect.
…
// Check the difference between the mouse position (Screen) …
If there is no error, can someone clarify my confusion? Where is the 0,0 placement for Input.mousePosition, and for GUI elements (like GUI.DrawTexture)?
Thanks,
~Nick.
Eric5h5
February 14, 2012, 12:46am
2
That’s the difference between screen space and GUI space. You don’t use Input.mousePosition (screen space) in OnGUI code, you use Event.current.mousePosition (GUI space).
–Eric
2 Likes
So, then if I understand you correctly:
Input.mousePosition has 0,0 at bottom left
Event.current.mousePosition has 0,0 at top left
GUI space has 0,0 at bottom left
Is that correct?
~Nick.
Eric5h5
February 14, 2012, 1:18am
4
Not quite; GUI space has 0,0 at top left. Screen space is 0,0 at bottom left.
–Eric
1 Like
Thanks for your Help Eric.
~Nick.
they should make it the same to prevent confusion
That’s not really feasible. Just remember to only use GUI functions with GUI code and there shouldn’t be any confusion.
–Eric
Edited: So to sum up for future readers…
GUI Space is (0,0) at the top left
Event.current.mousePosition will return mouse coordinates using GUI Space.
Screen Space is (0,0) at the bottom left
Input.mousePosition will return mouse coordinates using Screen Space.