using System.Collections.Generic; using RR.Common.Settings; using TMPro; using UnityEngine; namespace RR.Common.UI { public class SettingDropdownQualityBinder : 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; dropdown.ClearOptions(); dropdown.AddOptions(new List(QualitySettings.names)); 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)) ); } } }