示例
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;
}
}