33 lines
844 B
C#
33 lines
844 B
C#
|
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;
|
||
|
}
|
||
|
}
|