zoukankan      html  css  js  c++  java
  • unity Screen.orientation

    public static ScreenOrientation orientation ;

    Project Settings -> Player -> Resolution and Presentation -> Default Orientation,设置为:Auto Rotation 时,在进入应用且脚本运行Awake()函数及之后,默认会根据以下属性设置一个 ScreenOrientation,当屏幕发生旋转后也是如此。

    public static bool autorotateToPortrait ;
    public static bool autorotateToPortraitUpsideDown ;
    public static bool autorotateToLandscapeLeft ;
    public static bool autorotateToLandscapeRight ;
    
    注意:
    • 如果代码中动态设置 Screen.orientation 实现横竖屏切换时,Screen.width、Screen.height、Screen.safeArea 等属性并不会在 Screen.orientation 赋值后立刻发生变化,想知道屏幕是否已旋转,只能每一帧通过比较 Screen.orientation 和 Screen.width、Screen.height 的值进行判断。
    • Screen.width、Screen.height、Screen.safeArea 的值是根据当前的屏幕的旋转方向来设置的,假如手机屏幕的分辨率为1280x720,那么正面横向拿手机并且屏幕已旋转那么 Screen.width 等于1280,Screen.height 等于720,竖向拿则相反。一定需要注意的是 Screen.orientation 的值并不能作为 Screen.width、Screen.height、Screen.safeArea 已改变的唯一条件,它们的值只在 Screen.orientation 改变且手机屏幕已实际旋转后才会改变。
  • 相关阅读:
    题解【DP100题1~10】
    新博客已建好!
    题解【语文1(chin1)- 理理思维】
    题解【[BJOI2012]算不出的等式】
    题解【[HAOI2006]受欢迎的牛】
    题解【[FJOI2018]所罗门王的宝藏】
    Redis常用命令
    mysql table 最新更新时间
    中国翻译史阶记
    HTTP Session原理
  • 原文地址:https://www.cnblogs.com/kingBook/p/14085850.html
Copyright © 2011-2022 走看看