런타임에서 Screen Orientation 변경하기
2 분
기본적으로 표시될 화면 방향을 월드 설정에서 설정해 주세요.

- 방향 : 화면의 방향을 선택하세요.
- 세로
- 가로
다음은 런타임에 화면 방향을 변경하는 예제 코드입니다.
지원되는 화면 방향은 두 가지입니다: 세로 및 가로.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { Button } from 'UnityEngine.UI';
import { Screen, ScreenOrientation } from "UnityEngine";
export default class ChangeOrientation extends ZepetoScriptBehaviour {
public orientationBtn: Button;
Start() {
// 버튼 클릭 시
this.orientationBtn.onClick.AddListener(() => {
if(Screen.orientation == ScreenOrientation.Landscape)
{
// 화면 방향을 세로로 설정
Screen.orientation = ScreenOrientation.Portrait;
}
else
{
// 화면 방향을 가로로 설정
Screen.orientation = ScreenOrientation.Landscape;
}
});
}
}👍 팁
- 기본 UI(홈 버튼, 채팅 버튼) 및 V-pad는 화면 방향 변경 시 자동으로 가로-세로 전환을 지원합니다.
- 콘텐츠에 다른 사용자 정의 UI를 제공하는 경우 방향에 응답해야 합니다.