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); } }