CREATE YOUR WORLD
User Interface
Changing Screen Orientation at runtime
2min
please set the screen orientation to be displayed by default in world settings orientation choose the orientation of the screen vertical horizontal the following is an example code to change the orientation of the screen at runtime only two screen orientations are supported portrait and landscape changeorientation 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() { // when button click this orientationbtn onclick addlistener(() => { if(screen orientation == screenorientation landscape) { // set screen orientation portrait screen orientation = screenorientation portrait; } else { // set screen orientation landscape screen orientation = screenorientation landscape; } }); } } 👍 tip default ui (home button, chat button) and v pad automatically support landscape portrait switching when changing screen orientation if you provide other custom ui in your content, you need to respond to the orientation