Unity3d Coordinate System

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.