Files
ichni_Official/Assets/Scripts/UI/Base/Switch.cs

38 lines
914 B
C#
Raw Normal View History

2025-08-11 14:04:06 -04:00
using Michsky.MUIP;
namespace Ichni.UI
{
public class Switch : SettingsUIElementBase
{
public bool value;
public SwitchManager switchManager;
2026-07-19 16:44:58 -04:00
public void SetUp(bool initialValue, string title = "", bool preservePrefabTitle = false)
2025-08-11 14:04:06 -04:00
{
2026-07-19 16:44:58 -04:00
base.SetUp(title, preservePrefabTitle: preservePrefabTitle);
2025-08-11 14:04:06 -04:00
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;
}
}
2026-07-19 16:44:58 -04:00
}