Files
test/Assets/PerfectWorld/Scripts/UI/General/TwoStateToggle.cs
T
2026-01-29 17:42:34 +07:00

22 lines
636 B
C#

using UnityEngine;
using UnityEngine.UI;
public class TwoStateToggle : MonoBehaviour
{
[SerializeField] Toggle toggle;
[SerializeField] Transform HideStateObject;
[SerializeField] Transform ShowStateObject;
protected void Awake()
{
toggle.onValueChanged.AddListener(SetState);
}
protected void OnDestroy()
{
toggle.onValueChanged.RemoveAllListeners();
}
public void SetState(bool state)
{
HideStateObject.gameObject.SetActive(!state);
ShowStateObject.gameObject.SetActive(state);
}
}