43 lines
969 B
C#
43 lines
969 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using I2.Loc;
|
|
using Michsky.MUIP;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace Ichni.UI
|
|
{
|
|
public class Switch : SettingsUIElementBase
|
|
{
|
|
public bool value;
|
|
public SwitchManager switchManager;
|
|
|
|
public void SetUp(bool initialValue, string title = "")
|
|
{
|
|
base.SetUp(title);
|
|
|
|
switchManager.onValueChanged.AddListener(isOn =>
|
|
{
|
|
value = isOn;
|
|
updateValueAction?.Invoke();
|
|
});
|
|
|
|
SetValue(initialValue);
|
|
}
|
|
|
|
public void SetValue(bool value)
|
|
{
|
|
this.value = value;
|
|
switchManager.isOn = value;
|
|
if (switchManager.isInitialized){
|
|
switchManager.UpdateUI();
|
|
}
|
|
}
|
|
|
|
public bool GetValue()
|
|
{
|
|
return value;
|
|
}
|
|
}
|
|
} |