Unity: Camera screen resolution


The orthographicSize property defines the viewing volume of an orthographic Camera. In order to edit this size, set the Camera to be orthographic first through script or in the Inspector. The orthographicSize is half the size of the vertical viewing volume. The horizontal size of the viewing volume depends on the aspect ratio.


Using Camera > Projection > Ortographic, Unity will only take the Vertical units as the one being rendered onscreen, THEN render the horizontal lines that fit.

For example:

If you've set the Camera Size to 10, the playing area in Unity Editor will be 20x20 units, which is denoted by the lines (remember, the size is counted starting from the center, so 10 to the left, 10 to the right, 10 upwards, 10 downwards, so 20x20).

Then, let's say you try to publish on a screen that is 300x400  resolution. Then, Unity will fit 20 units vertically at first so that it fits the screen. So each unit will have 400/20 = 20 pixels.

However, the screen only has 300 pixels horizontally. So the screen can only fit 300/20 = 15 Unity units. So only 7.5 Unity units from the origin will be rendered horizontally. So the whole thing being rendered in Unity units is 20x15. 

Make sense?

How about the UI?


1. On your canvas, set the Canvas Scaler component's Ui Scale Mode to Scale with Screen Size. Then you can define a Reference Resolution of 1080p, i.e. 1920 x 1080.

2. To see the canvas fit into the camera's size in the scene, change the Canvas component's Render Mode to Screen Space - Camera, and drag the camera from the hierarchy to it.

3. Me: Set the UI Scale Mode to Scale with Screen Size

4. Me: Lastly, set the Screen Match Mode to "Match Width or Height". Then, set the "Match" value to "Height" (You can also set it to 0.5 if your game is both horizontal/vertical). So now the canvas will act like a Camera as well, will first adjust to the correct height first, then fill in the rest.


youtube: https://www.youtube.com/watch?v=svyDgYz5idg