Game Development Reference
In-Depth Information
Figure 6-14.
Weapon sprite too small at 1:1 orthographic size
The answer is, by default, Unity applies
additional scaling
to all 2D sprites. To examine this, select the
main texture in the Project panel and examine the
Pixels to Units
field in the Object Inspector. For the
CMOD texture, this value is 200. This means all sprites are scaled automatically such that 200 texels
(texture pixels) are mapped to 1 world unit. For this reason, a 1:1 orthographic size for a camera will
render the sprites and textures
200
times
too small
for pixel perfection. Therefore, to create pixel-perfect
mapping, we'll need to revise the orthographic size formula to:
Size = pxHeight/2/SpriteScale.
Thus,
for a 1024×768 game, it should be
768 / 2 / 200
. Take a look at Figure
6-15
, where things are looking
better, and pixel-perfect. But don't celebrate just yet! There's still an issue to resolve . . .
Figure 6-15.
Pixel-perfect weapons!