using UnityEngine; using UnityEngine.UI; namespace SpellBoundAR.Items.Selections.Static { [DisallowMultipleComponent] [RequireComponent(typeof(Image))] public class StaticSelectedItemTypeImage : MonoBehaviour { [Header("Cache")] private Image _image; private void Awake() { _image = GetComponent(); } private void OnEnable() { StaticSelectedItemTypeManager.OnSelectionChanged += Refresh; Refresh(); } private void OnDisable() { StaticSelectedItemTypeManager.OnSelectionChanged -= Refresh; } private void Refresh() { if (!_image) return; _image.sprite = StaticSelectedItemTypeManager.CurrentSelection != null ? StaticSelectedItemTypeManager.CurrentSelection.Depiction : null; _image.color = _image.sprite ? Color.white : Color.clear; _image.preserveAspect = true; } } }