脚本设置屏幕分辨率

作者:追风剑情 发布于:2019-5-29 10:59 分类:Unity3d

示例

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScreenResolution : MonoBehaviour
{
    [Header("分辨率")]
    public int width = 1920;
    public int height = 1080;
    public int refreshRate = 0;
    public bool fullscreen = true;
    public ESleepTimeout sleepTimeout = ESleepTimeout.SystemSetting;

    //参见SleepTimeout类中定义的常量
    public enum ESleepTimeout
    {
        NeverSleep = -1,
        SystemSetting = -2,
    }

    void Awake ()
    {
        Screen.SetResolution(width, height, fullscreen, refreshRate);
        Screen.sleepTimeout = (int)sleepTimeout;
    }
}

11111.png

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号