unity 设置屏幕旋转


只允许竖屏:

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;//再设置为允许自动旋转
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM