#if INPUTSYSTEM_SUPPORT using AlicizaX.UI.Runtime; using UnityEngine; namespace AlicizaX.UI { // [DisallowMultipleComponent] public class HotkeyBindComponent : MonoBehaviour { private UIHolderObjectBase _holderObjectBase; private void Awake() { _holderObjectBase = GetComponent(); _holderObjectBase.OnWindowShowEvent += BindHotKeys; _holderObjectBase.OnWindowClosedEvent += UnBindHotKeys; } private void OnDestroy() { _holderObjectBase.OnWindowShowEvent -= BindHotKeys; _holderObjectBase.OnWindowClosedEvent -= UnBindHotKeys; } [SerializeField] private UXHotkeyButton[] hotButtons; internal void BindHotKeys() { for (int i = 0; i < hotButtons.Length; i++) { hotButtons[i].BindHotKey(); } } #if UNITY_EDITOR [ContextMenu("Bind HotKeys")] private void CollectUXHotkeys() { hotButtons = gameObject.GetComponentsInChildren(true); } #endif internal void UnBindHotKeys() { for (int i = 0; i < hotButtons.Length; i++) { hotButtons[i].UnBindHotKey(); } } } } #endif