using UnityEngine; namespace SpellBoundAR.CustomTextures.UI { [RequireComponent(typeof(CustomTextureIndex))] public class CustomTextureIndexCloseOnTextureSelected : MonoBehaviour { [Header("Cache")] private CustomTextureIndex _index; private void Awake() { _index = GetComponent(); } private void OnEnable() { if (_index) _index.SelectionManager.OnSelectionChanged += OnSelectionChanged; OnSelectionChanged(); } private void OnDisable() { if (_index) _index.SelectionManager.OnSelectionChanged -= OnSelectionChanged; } private void OnSelectionChanged() { if (_index && _index.SelectionManager.CurrentSelection != null) _index.Close(); } } }