发布设置
Edit →Project Setting →Player →Resolution and Presentation →Default Orientation*
Portrait 纵向锁定
Portrait Upside Down 倒置纵向锁定
Landscape Right 右横向锁定
Landscape Left 左横向锁定
Auto Rotation 自动旋转(开启时可自定义旋转锁定方向)
Use Animated Autorotation 使用带动画的转向(仅iOS 开启自动旋转时适用)
动态修改
纵向锁定
Screen.orientation = ScreenOrientation.Portrait;
倒置纵向锁定
Screen.orientation = ScreenOrientation.PortraitUpsideDown;
横向锁定
Screen.orientation = ScreenOrientation.Landscape;
右横向锁定
Screen.orientation = ScreenOrientation.LandscapeRight;
左横向锁定
Screen.orientation = ScreenOrientation.LandscapeLeft;
自动旋转
Screen.orientation = ScreenOrientation.AutoRotation;
Screen.autorotateToLandscapeRight = true;
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToPortrait = true;
Screen.autorotateToPortraitUpsideDown = true;