35 lines
916 B
C#
35 lines
916 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);
|
|
}
|
|
} |