Understanding Unity 3D coordinate systems

Unity 3D has 4 coordinate systems: World, Screen, Viewport and UI.

The world coordinate system is left handed (as Direct X) where x positive axis is right, y positive is up and z is positive into the screen.

Screen coordinate system is bottom-up: (0,0) at bottom-left corner and (pixelWidth-1,pixelHeight-1) at right-top; x axis is positive right and y is positive up. The z position is in world units from the camera.

Viewport coordinate system is normalized and relative to the camera, so the bottom-left point is (0,0), the top-right is (1,1). The z position is in world units from the camera.

Finally UI coordinate system is top-down: the y coordinate varies from zero at the top edge of the window to a maximum at the bottom edge of the window. The upper-left point is (0,0); the bottom-right is (1,1)

There are many functions to convert between all these different coordinate systems, see
Camera.WorldToScreenPoint
Camera.WorldToViewportPoint
Camera.ScreenToViewportPoint
Camera.ScreenToWorldPoint
Camera.ViewportToScreenPoint
Camera.ViewportToWorldPoint
GUIUtility.ScreenToGUIPoint
GUIUtility.GUIToScreenPoint

 

Leave a Reply