How to make number of blocks fit the screen space horizontaly and vertically ?

I am trying to fit border blocks around the camera space.
If I am running on 1920x1080 resolution and the block sprite is 120x120 pixels(because it divides with 1920 and 1080 with no floating point leftover) and I set the pixels per unit to be 120 in the sprite inspector and start to align them together on the horizontal part I do actually get a leftover, how is that possible ?
how can i make the blocks align perfectly on the camera space ?
If I calculate 1080 / 120 I get 9 but the blocks seem to be 10.
The number for 1920 / 120 is 16 but I

get 18 blocks aligned instead.
Am I missing something here ?

I know this is an old question. But for those that get here through google…

The problem stems from the default value of the Orthographic camera which is 5.


This means that the vertical size is actuallt 10 Unity Units height.

And 17.777777 Unity Units width.

So when you set the pixels per unit to 120 this makes it so that 10 images fit accross and 17.777777 fit vertically.

The issue here can be solved in several ways.


Solution1:

Set the camera size to 4.5. Doing this will make it so that there are 9 Unity Units in height and 16 accross the width. So by doing this when you set 120 Pixels Per Unit you will effectively get exactly 9 images in height and 16 in width to fit your screen.

Solution2:

Set the camera size to 5.4 and leave the default of 100 pixels per unit on the images.
This will have the same effect of being able to fit get exactly 9 images in height and 16 in width to fit your screen.

A couple or formulas to help you:

Correct Ortographics Camera size for a particular pixel per unit setting:

Ortographic Size = Desired Height / (2 X pixels per unit)


Number of width units based on the aspect ratio and camera size:

Width in Units =( (Ortographic Size X 2) / Aspect Ratio Height) X Aspect Ratio Width