123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class resolution : MonoBehaviour {
-
- int index = 0;
- private Resolution[] resolutionList;
-
-
-
- public Resolution Get_resolution
- {
- get { return resolutionList[index]; }
- }
- [SerializeField]
- private Dropdown resoluDropdown;
- [SerializeField]
- private Toggle FWtg;
- public bool FullWindow { get; set; }
-
-
- private void Start()
- {
-
-
-
- FullWindow = Screen.fullScreen;
- FWtg.isOn = FullWindow;
-
- resolutionList = new Resolution[Screen.resolutions.Length-6];
-
-
- List<string> DropdownList = new List<string>();
- for (int i = 0; i < resolutionList.Length; i++)
- {
- resolutionList[i] = Screen.resolutions[i+6];
- DropdownList.Add(resolutionList[i].width + " × " + resolutionList[i].height);
-
- }
-
- resoluDropdown.AddOptions(DropdownList);
- int _width = Screen.currentResolution.width;
- int _height = Screen.currentResolution.height;
-
- for (int i = 0; i < resolutionList.Length; i++)
- {
- if (resolutionList[i].width == _width && resolutionList[i].height == _height)
- {
- index = i;
- continue;
- }
- }
-
- resoluDropdown.value = index;
-
-
- }
- public void FullWindowToggle(Toggle tg) {
- FullWindow = tg.isOn;
-
- }
-
- public void indexChange()
- {
- index = resoluDropdown.value;
-
- var _width = resolutionList[index].width;
- var _height = resolutionList[index].height;
-
- Screen.SetResolution(_width, _height, FullWindow);
-
- }
- }
|