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 改变且手机屏幕已实际旋转后才会改变。
  • 相关阅读:
    图片不能显示
    Lambda表达式where过滤数据
    存储文本到一个文件里
    获取用户临时文件夹路径
    判断某一个字符串是否存在另一个字符串中
    使用反射为特性赋值
    字符串与数据流之间的转换
    控制台应用程序获取计算机名
    重复输出字符或字符串
    使用HashSet<>去除重复元素的集合
  • 原文地址:https://www.cnblogs.com/kingBook/p/14085850.html
Copyright © 2011-2022 走看看