在unity制作2D游戲的教程,背景圖sprite鋪滿顯示時Camaer的Size調到多少合適,作個筆記。
資源參數
background.png 2048x640,Sprite的像素單位:100
調節camera.size
當camera的size=5,背景的顯示效果
Camera的Size=3.2的背景的顯示效果
計算公式
計算公式為:Screen Height/2/Pixel To Units=Main Camera.Size
對於2048x640的背景圖,像素為100單位的比例,Camera的Size=640/2/100=3.2
For example, consider a Sprite imported from a 500 pixels wide image. The following table shows the different widths your GameObject would have when rendering that Sprite at different scales along the x-axis, using different values for Pixels to Units:
background.png is 640 pixels tall, and the background Sprite has a Pixel to Unit ratio of 100, so the background
object in the Hierarchy will be 6.4
units tall. However, the orthographic camera’s Size property measures half the height of the screen, so it should be half the height of the background, in units, or 3.2
.