revival/game/Assets/Scripts/Settings/ResolutionPicker.cs

33 lines
844 B
C#
Raw Permalink Normal View History

2021-03-08 17:26:33 +01:00
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(TMP_Dropdown))]
public class ResolutionPicker : MonoBehaviour
{
private void Awake()
{
var dropdown = GetComponent<TMP_Dropdown>();
var resolutions = Screen.resolutions;
dropdown.options.Clear();
var options = new List<TMP_Dropdown.OptionData>();
foreach (var res in GraphicsSettings.RESOLUTIONS)
{
var data = new TMP_Dropdown.OptionData
{
image = null,
text = $"{res.width} x {res.height}"
};
options.Add(data);
}
dropdown.AddOptions( options );
dropdown.value = resolutions.Length - 1;
}
}