using UnityEngine; using UnityEngine.UI; namespace SpellBoundAR.Items.Selections.UI { [DisallowMultipleComponent] [RequireComponent(typeof(Image))] public class ItemTypeSelectionButtonOutline : MonoBehaviour { [Header("Cache")] private ItemTypeSelectionButton _itemTypeSelectionButton; private Image _image; public void Awake() { _itemTypeSelectionButton = GetComponentInParent(); _image = GetComponent(); } private void OnEnable() { if (_itemTypeSelectionButton) _itemTypeSelectionButton.OnIsSelectedChanged += Refresh; Refresh(); } private void OnDisable() { if (_itemTypeSelectionButton) _itemTypeSelectionButton.OnIsSelectedChanged -= Refresh; } private void Refresh() { if (_image) _image.enabled = _itemTypeSelectionButton && _itemTypeSelectionButton.IsSelected; } } }