Performance: 2D camera setup
This affects the rendering speed and smoothness of the 2D game view by controlling what and how much is drawn on screen.
Camera.main.orthographicSize = 5; // Small view focused on player area Camera.main.cullingMask = LayerMask.GetMask("Player", "Environment"); // Only render needed layers
Camera.main.orthographicSize = 1000; // Very large view showing many off-screen objects Camera.main.cullingMask = ~0; // Render all layers including unused ones
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large orthographic size with all layers | N/A | N/A | High GPU overdraw and many draw calls | [X] Bad |
| Small orthographic size with limited layers | N/A | N/A | Low GPU overdraw and fewer draw calls | [OK] Good |
Orthographic mode in a 2D game?orthographic to switch modes.camera.orthographic = true;. Other options use incorrect property names or methods.Camera.main.orthographicSize = 5f; Debug.Log(Camera.main.orthographicSize);What will be printed in the console?
orthographicSize controls half the vertical size of the camera view in world units and can be set and read.orthographicSize to 5f, then logs it. So the output will be 5.void Update() {
Vector3 targetPos = player.transform.position;
targetPos.z = -10;
transform.position = targetPos;
}
The camera jumps abruptly instead of moving smoothly.Vector3.Lerp blends current and target positions over time, creating smooth camera movement.Pass the test and this pattern moves unknown