using UnityEngine; using UnityEngine.UI; namespace Cielonos.Settings.UI { /// /// bool 字段的设置条目 — 使用 Toggle 组件。 /// public class SettingsEntryToggle : SettingsEntryBase { [SerializeField] private Toggle toggle; protected override void SetupUI() { if (toggle != null) toggle.onValueChanged.AddListener(OnToggleChanged); } public override void RefreshValue() { if (toggle != null) toggle.SetIsOnWithoutNotify((bool)GetFieldValue()); } private void OnToggleChanged(bool value) { SetFieldValue(value); } private void OnDestroy() { if (toggle != null) toggle.onValueChanged.RemoveListener(OnToggleChanged); } } }