In Unity3D, to draw an object on the screen, you need a camera. Unity's camera supports two modes:正交投影
透视投影
For 2D development we are using 正交模式
, below is the orthographic camera in the Unity scene.
As you can see, the frustum of the orthographic camera is a cuboid
2D camera properties
Several properties in the Camera component are described below:
- Clear Flags: Determines which parts of the camera will be cleared, useful when rendering elements in a scene with multiple cameras
- Background: The camera will render the screen to the current color before rendering
- Culling Mask: Select the layer to be culled by the camera
- Projection: Select the projection mode
- Orthographic: Orthographic projection mode
- Perspective: Perspective projection mode
- Size: The viewport size of the orthographic camera (when Orthographic is selected for Projection)
- Fild Of View: The view angle of the camera (Projection selects Perspective)
- Clipping Planes: The distance between the start and end of the camera rendering
- Near: Near section distance
- Far: far section distance
- Viewport Rect: Four values to indicate where the camera will draw the image on the screen
- x: The position where the camera view starts to draw on the horizontal axis
- y: The position where the camera view starts to draw on the vertical axis
- w: the width of the camera output image on the screen
- h: the height of the camera output image on the screen
- Depth: The position of the camera in the drawing sequence. Cameras with higher values will draw the image above cameras with lower values
- Rendering Path: Set the rendering mode of the camera
- Use Player Settings: The camera will render in the mode set by the user
- Vertex Lit: All objects rendered with this camera will be treated as vertex lighting objects
- Forward: All objects rendered with this camera will be rendered with one pass per material
- Deferred Lighting: All objects rendered with this camera will be drawn once with no lighting, then all objects' lighting will be rendered together at the end of the render queue
- TargetTexture: Please refer to Render Texture, this page contains the output of the camera view. This reference property will disable the camera's ability to render to the screen