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