Mobile Aspect Ratio - TeamCrazyPerformance/Game_study GitHub Wiki
- ๋น๋ ์ธํ ์ ์๋๋ก์ด๋๋ก ์ค์
- ๋ชจ๋ฐ์ผ ํด์๋ ์กฐ์ฌ ๋ฐ ์ ์ (2160 * 1080 Landscape)
- canvas ์ค์
- ProjectSetting์์ ํ๋ฉด ํ์ ์ค์
- ๋ชจ๋ ์ฌ ์นด๋ฉ๋ผ์ ์ ์ฉ
public class CameraResolution : MonoBehaviour
{
void Awake()
{
Camera camera = GetComponent();
Rect rect = camera.rect;
float scaleheight = ((float)Screen.width / Screen.height) / ((float)16 / 9); // (์ธ๋ก / ๊ฐ๋ก)
float scalewidth = 1f / scaleheight;
if (scaleheight < 1)
{
rect.height = scaleheight;
rect.y = (1f - scaleheight) / 2f;
}
else
{
rect.width = scalewidth;
rect.x = (1f - scalewidth) / 2f;
}
camera.rect = rect;
}
void OnPreCull() => GL.Clear(true, true, Color.black);
}