脚本设置屏幕分辨率

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

示例

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ScreenResolution : MonoBehaviour
  6. {
  7. [Header("分辨率")]
  8. public int width = 1920;
  9. public int height = 1080;
  10. public int refreshRate = 0;
  11. public bool fullscreen = true;
  12. public ESleepTimeout sleepTimeout = ESleepTimeout.SystemSetting;
  13.  
  14. //参见SleepTimeout类中定义的常量
  15. public enum ESleepTimeout
  16. {
  17. NeverSleep = -1,
  18. SystemSetting = -2,
  19. }
  20.  
  21. void Awake ()
  22. {
  23. Screen.SetResolution(width, height, fullscreen, refreshRate);
  24. Screen.sleepTimeout = (int)sleepTimeout;
  25. }
  26. }

11111.png

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号