sega d284694456 Проработка настроек
- Переходы из и в меню
- Триггер изменения настроек
- Сохранение настроек при выходе
2026-08-21 10:36:27 +03:00

36 lines
966 B
C#

using UnityEngine;
public class IntView : BaseSettingView
{
[SerializeField] private MNumberStepper _stepper;
[Header("Звук")]
[SerializeField] private AudioClip SwitchClip;
[SerializeField] private AudioSource Source;
public override SettingDTO CachedSetting { get; set; }
public override void Initialize(SettingDTO setting)
{
base.Initialize(setting);
CachedSetting = setting;
if (Source != null && SwitchClip != null)
Source.clip = SwitchClip;
_stepper.Initialize(setting.IntValue, setting.IntMin, setting.IntMax);
_stepper.OnValueChanged += OnValueChanged;
}
public override void TakeInput(int direction, bool _)
{
_stepper.SetDirection(direction);
}
private void OnValueChanged(int newValue)
{
CachedSetting.IntValue = newValue;
Source.PlayOneShot(SwitchClip);
SettingsManager.TriggerSettingsChanged();
}
}