Camera.orthographicSize

Did you know that the camera is half-size when in orthographic mode? Well I didn’t, but now I do.

The orthographicSize property defines the viewing volume of an  orthographic  Camera. In order to edit this size, ensure the Camera is first set to orthographic either 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.

So if I wanted to create a bounding box around the orthographic camera view – for example in a game where I wanted to know if an object has left the gameplay area which is the whole screen – then I could use the following script.

Vector3 scaleDesiredOfColiderBox;

scaleDesiredOfColiderBox.z = 10;
scaleDesiredOfColiderBox.y = Camera.main.orthographicSize * 2;
scaleDesiredOfColiderBox.x = scaleDesiredOfColiderBox.y * Camera.main.aspect;