-
Notifications
You must be signed in to change notification settings - Fork 0
Mobile Aspect Ratio
Seong Hyeok OH edited this page Mar 25, 2023
·
1 revision
- 빌드 세팅을 안드로이드로 설정
- 모바일 해상도 조사 및 선정(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);
}