76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BTN_OptionsResolution : MonoBehaviour
|
|
{
|
|
private Dropdown dropdown;
|
|
|
|
private void Start()
|
|
{
|
|
InitList();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
InitList();
|
|
}
|
|
|
|
private void InitList()
|
|
{
|
|
dropdown = base.gameObject.GetComponent<Dropdown>();
|
|
int num = PlayerPrefs.GetInt("Screenmanager Resolution Width");
|
|
int num2 = PlayerPrefs.GetInt("Screenmanager Resolution Height");
|
|
int refreshRate = Screen.currentResolution.refreshRate;
|
|
Debug.LogError("Screen: " + Screen.width + " x " + Screen.height);
|
|
Debug.LogError("Screen.currentResolution: " + Screen.currentResolution.width + " x " + Screen.currentResolution.height + " Refresh: " + Screen.currentResolution.refreshRate);
|
|
Debug.LogError("PlayerPrefs: " + PlayerPrefs.GetInt("Screenmanager Resolution Width") + " x " + PlayerPrefs.GetInt("Screenmanager Resolution Height"));
|
|
dropdown.options.Clear();
|
|
dropdown.options.Capacity = 0;
|
|
int num3 = -1;
|
|
int num4 = -1;
|
|
for (int i = 0; i < Screen.resolutions.Length; i++)
|
|
{
|
|
dropdown.options.Add(new Dropdown.OptionData(string.Empty + Screen.resolutions[i].width + " x " + Screen.resolutions[i].height + " " + Screen.resolutions[i].refreshRate + "Hz"));
|
|
if (Screen.resolutions[i].width == num && Screen.resolutions[i].height == num2)
|
|
{
|
|
num3 = i;
|
|
if (Screen.resolutions[i].refreshRate == refreshRate)
|
|
{
|
|
num4 = i;
|
|
}
|
|
}
|
|
}
|
|
if (num4 > -1)
|
|
{
|
|
dropdown.value = num4;
|
|
}
|
|
else if (num3 > -1)
|
|
{
|
|
dropdown.value = num3;
|
|
Debug.LogError("currentRefreshRateResolution == -1");
|
|
}
|
|
else
|
|
{
|
|
dropdown.value = 0;
|
|
Debug.LogError("currentRefreshRateResolution == -1 && currentResolution == -1");
|
|
}
|
|
dropdown.RefreshShownValue();
|
|
}
|
|
|
|
public void UpdateResolution()
|
|
{
|
|
if (dropdown.value >= 0 && dropdown.value < Screen.resolutions.Length)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.ChangeResolution(Screen.resolutions[dropdown.value].width, Screen.resolutions[dropdown.value].height, Screen.fullScreen, Screen.resolutions[dropdown.value].refreshRate);
|
|
}
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.RenderAllProbes();
|
|
}
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.RefreshAll();
|
|
}
|
|
}
|
|
}
|