using UnityEngine; using UnityEngine.UI; public class EquipmentOnlyBoughtToggle : MonoBehaviour { public bool onlyBought = true; [HideInInspector] public Toggle toggle; private EquipmentGUI equipmentGUI; private void OnEnable() { if (toggle == null) { toggle = GetComponent(); } if (!equipmentGUI) { equipmentGUI = Object.FindObjectOfType(); } } public void ValueChanged() { if ((bool)equipmentGUI && (bool)equipmentGUI.equipmentManager && toggle.isOn && onlyBought != equipmentGUI.showOnlyBought) { equipmentGUI.ShowOnlyBought(onlyBought); } } }