Unity3D Correct Orthographic Size of Camera

后端 未结 1 1037
傲寒
傲寒 2020-12-18 15:23

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 i

相关标签:
1条回答
  • 2020-12-18 15:39

    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.

    0 讨论(0)
提交回复
热议问题