본문 바로가기

Unity/팁

[Unity 유니티] Orientation 화면 회전 / Portrait 세로 Landscape 가로

1. Portrait - 세로

2. Portrait Upside Down - 세로 (위아래 반대)

3. Landscape Left - 가로 (왼쪽으로 회전)

4. Landscape Right - 가로 (오른쪽으로 회전)

5. Auto Rotation - 자동회전


Orientation 설정 방법

File > Build Settings > Player Settings > Resolution and Presentation > Default Orientation

필요에 따라 Landscape Left, Landscape Right, Auto Rotation 등으로 변경할 수 있다.

Auto Rotation을 선택한 경우, 추가 옵션이 나타나며 허용할 방향을 개별적으로 체크할 수 있다. 예를 들어, Portrait와 Landscape 모드 중 개발자가 원하는 방향만 선택하여 활성화할 수 있다. 이를 통해 불필요한 화면 전환을 방지하고, 사용자가 원치 않는 방향 전환으로 인한 혼란을 최소화할 수 있다.


코드로 Orientation 변경하기

게임 실행 도중 동적으로 Orientation을 변경하고자 할 경우, 코드로도 제어가 가능하다. 아래는 간단한 코드 예시다.

Screen.orientation = ScreenOrientation.LandscapeLeft;

Screen.orientation = ScreenOrientation.Portrait;

이와 같이 코드를 사용하면 게임 실행 중에도 사용자의 상황에 맞게 화면 방향을 조정할 수 있다.