Unity3D Correct Orthographic Size of Camera

2020-02-11 13:47发布

For 2D game, default camera(orthographic) size is 5 and I am trying to figure out what it should be to get original views of images. What should it be? Because 5 shows the images very smaller than original size.

1条回答
一纸荒年 Trace。
2楼-- · 2020-02-11 14:24

First scale the cameras transform to 2/screenHeight, so if you have 1920x1080 screen it should be 2/1080

Then set your cameras orographic size to 1

Then on the sprite, set the "pixels to units" to the height of the image size, so if you have a image of size 128x128 the pixels to units should be 128

Now if you place your sprite as a child to your camera, the scale of the object will be in pixels. so if you want a sprite of size 128x128 to be 128x128 on a 1080 screen just set the scale of the transform to 128,128,0

The bonus of doing it this way is that you design the game for one resolution like 1920x1080 and when you run it on a screen with another resolution (same aspect ratio) you just need to change the 2/screenHeight for the camera and everything will have the same relative size which will make it look the same as long as the aspect ratio is the same.

查看更多
登录 后发表回答