unity 设置屏幕旋转

时间:2021-01-01 10:22:31

只允许竖屏:

Portrait                    √

Portrait Upside Down √

Landscape Right        ×

Landscape Left          ×

只允许横屏:

Portrait                    ×

Portrait Upside Down ×

Landscape Right        √

Landscape Left          √

代码动态设置屏幕旋转:

private void setLandscape(){
Screen.orientation=ScreenOrientation.Landscape;//如果屏幕是竖屏,则立刻旋转至横屏 //设置只允许横屏旋转
Screen.autorotateToPortrait =false;
Screen.autorotateToPortraitUpsideDown =false;
Screen.autorotateToLandscapeRight =true;
Screen.autorotateToLandscapeLeft =true; Screen.orientation=ScreenOrientation.AutoRotation;//再设置为允许自动旋转
}