using System.Collections.Generic; using RR.Common.Settings; using TMPro; using UnityEngine; namespace RR.Common.UI { public class SettingDropdownResolutionBinder : MonoBehaviour { [SerializeField] private string key; [SerializeField] private TMP_Dropdown dropdown; [SerializeField] private TMP_Text label; private SettingEntry def; private void Start() { def = SettingsManager.Instance.Define(key); if (def == null) { gameObject.SetActive(false); return; } if (label) label.text = def.displayName; var rs = Screen.resolutions; var options = new List(); for (int i = 0; i < rs.Length; i++) options.Add($"{rs[i].width} x {rs[i].height}"); dropdown.ClearOptions(); dropdown.AddOptions(options); int current = SettingsManager.Instance.Get(key).i; current = Mathf.Clamp(current, 0, dropdown.options.Count - 1); dropdown.SetValueWithoutNotify(current); dropdown.onValueChanged.AddListener(idx => SettingsManager.Instance.Set(key, SettingValue.Int(idx)) ); } } }