Screen (Mouse) Coordinates vs GUI Coordinates

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:

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.

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.

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.