阶段性完成
This commit is contained in:
@@ -6,20 +6,27 @@ namespace Ichni.UI
|
||||
{
|
||||
public bool value;
|
||||
public SwitchManager switchManager;
|
||||
private bool _isValueChangeListenerRegistered;
|
||||
|
||||
public void SetUp(bool initialValue, string title = "", bool preservePrefabTitle = false)
|
||||
public void SetUp(bool initialValue, bool preservePrefabTitle = true)
|
||||
{
|
||||
base.SetUp(title, preservePrefabTitle: preservePrefabTitle);
|
||||
base.SetUp(preservePrefabTitle);
|
||||
|
||||
switchManager.onValueChanged.AddListener(isOn =>
|
||||
if (!_isValueChangeListenerRegistered)
|
||||
{
|
||||
value = isOn;
|
||||
updateValueAction?.Invoke();
|
||||
});
|
||||
switchManager.onValueChanged.AddListener(OnSwitchValueChanged);
|
||||
_isValueChangeListenerRegistered = true;
|
||||
}
|
||||
|
||||
SetValue(initialValue);
|
||||
}
|
||||
|
||||
private void OnSwitchValueChanged(bool isOn)
|
||||
{
|
||||
value = isOn;
|
||||
updateValueAction?.Invoke();
|
||||
}
|
||||
|
||||
public void SetValue(bool value)
|
||||
{
|
||||
this.value = value;
|
||||
|
||||
Reference in New Issue
Block a user