using System; using UnityEngine; using UnityEngine.UI; using UnityEngine.Serialization; namespace OHM.UnityToolkit { [RequireComponent(typeof(Toggle))] public class UIToggleOffGraphic : MonoBehaviour { [SerializeField] [FormerlySerializedAs("offGraphic")] private Graphic _offGraphic; [SerializeField] private Toggle toggle; private void Awake() { ComponentsUtils.GetRequiredComponent(base.transform, ref toggle); toggle.onValueChanged.AddListener(OnToggleChanged); } private void OnToggleChanged(bool value) { if (_offGraphic != null) { _offGraphic.gameObject.SetActive(!toggle.isOn); } } } }