【Unity3d Coordinate System]
1. World Space (World coordinates): We add objects (such as cubes) in the scene. They are all displayed in the world coordinates. Transform. position can obtain the coordinates of the position.
2. Screen Space (screen coordinates): defined in pixels, at (0, 0) in the lower left corner of the screen,The upper right corner is (screen. Width, screen. height)The position of Z is measured by the unit of the camera in the world. Note: The coordinates of the mouse position are screen coordinates,Input. mousepositionYou can obtain the coordinates of the position, and touch the screen with your fingers,Input. gettouch (0). PositionYou can obtain the screen coordinates of a single finger.
3. viewport space (view coordinate): The view coordinate is standard and relative to the camera. The lower-left corner of the camera is (), and the upper-right corner is (). The Z position is measured in the unit of the camera's world.
4. Coordinate System for drawing the GUI interface: the coordinate system is similar to the screen coordinate system. The difference is that the coordinate system is at (0, 0) points in the upper left corner of the screen,(Screen. Width, screen. Height).
【Conversion of Four Coordinate Systems]
1. World coordinates → screen coordinates: Camera. worldtoscreenpoint (transform. position); in this way, the world coordinates can be converted to screen coordinates. Camera is the camera object in the scenario.
2. screen coordinates → View coordinates: Camera. screentoviewportpoint (input. gettouch (0). position); in this way, the screen coordinates can be converted to the view coordinates. Camera is the camera object in the scenario.
3. View coordinates → screen coordinates: Camera. viewporttoscreenpoint ();
4. View coordinates → world coordinates: Camera. viewporttoworldpoint ();
Reference: http://www.juziku.com/wiki/53595.htm