Screen

public class Lesson12 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        #region 静态属性
        //获取屏幕分辨率,获取显示器的分辨率
        Resolution r = Screen.currentResolution;
        print(r.width+" "+r.height);
        //获取屏幕窗口当前的宽高,当前游戏窗口的宽高,不是显示器分辨率
        print(Screen.width+" "+Screen.height);

        //屏幕休眠模式
        //永不休眠
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        //运行时是否全屏
        Screen.fullScreen = true;
        //窗口模式
        //独占全屏ExclusiveFullScreen
        //全屏窗口MaximizedWindow
        //最大化窗口FullScreenMode.Windowed
        //窗口模式FullScreenMode.Windowed
        Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;

        //移动设备屏幕旋转相关
        //允许自动旋转为左横向 home键在左
        Screen.autorotateToLandscapeLeft = true;
        //允许自动旋转为右横向 home键在右
        Screen.autorotateToLandscapeRight = true;
        //允许自动旋转为纵向 home键在下
        Screen.autorotateToPortrait = true;
        //允许自动旋转为逆纵向 home键在上
        Screen.autorotateToPortraitUpsideDown = true;

        //指定屏幕显示方向
        Screen.orientation = ScreenOrientation.AutoRotation;
        #endregion

        #region 静态方法
        //设置分辨率 一般移动设备不用
        Screen.SetResolution(1920, 1080, false);//false=>非全屏 true =>全屏
        #endregion
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
posted @ 2025-03-16 17:54  cannedmint  阅读(12)  评论(0)    收藏  举报