32 lines
725 B
C#
32 lines
725 B
C#
using UnityEngine;
|
|
|
|
public class BoolView : BaseSettingView
|
|
{
|
|
[SerializeField] private MToggle _toggle;
|
|
|
|
public bool Value { get; private set; }
|
|
public SettingDTO CachedSetting { get; private set; }
|
|
|
|
public override void Initialize(SettingDTO setting)
|
|
{
|
|
base.Initialize(setting);
|
|
|
|
Value = setting.BoolValue;
|
|
CachedSetting = setting;
|
|
|
|
_toggle.DisplayImmediate(Value);
|
|
}
|
|
|
|
public override void TakeInput(int direction, bool _)
|
|
{
|
|
if (direction == 0) return;
|
|
|
|
bool newValue = direction > 0;
|
|
if (newValue == Value) return;
|
|
|
|
Value = newValue;
|
|
CachedSetting.BoolValue = Value;
|
|
|
|
_toggle.SetValue(Value);
|
|
}
|
|
} |