Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
- Добавил новую систему настроек, возможности:
- Динамически создает список настроек
- Сохраняет настройки в JSON-файл
- Возможность группировать настройки
- Широкие возможности по кастомизации
- Применение настроек в реальном времени (частично)
- Добавил префабы для новых элементов настроек
- Изменил поведение игры исходя из нового формата настроек
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
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<string>(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))
|
|
);
|
|
}
|
|
}
|
|
} |