2025-10-13 20:20:01 +08:00
|
|
|
#if INPUTSYSTEM_SUPPORT
|
2025-09-25 11:09:09 +08:00
|
|
|
using AlicizaX.UI.Runtime;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace AlicizaX.UI.Extension.UXComponent.Hotkey
|
|
|
|
|
{
|
2025-10-22 15:24:47 +08:00
|
|
|
[DisallowMultipleComponent]
|
2025-09-25 11:09:09 +08:00
|
|
|
public class HotkeyBindComponent : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private UIHolderObjectBase _holderObjectBase;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_holderObjectBase = GetComponent<UIHolderObjectBase>();
|
|
|
|
|
_holderObjectBase.OnWindowShowEvent += BindHotKeys;
|
|
|
|
|
_holderObjectBase.OnWindowClosedEvent += UnBindHotKeys;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
_holderObjectBase.OnWindowShowEvent -= BindHotKeys;
|
|
|
|
|
_holderObjectBase.OnWindowClosedEvent -= UnBindHotKeys;
|
|
|
|
|
}
|
|
|
|
|
[SerializeField]
|
2025-10-13 20:20:01 +08:00
|
|
|
private UXHotkey[] hotButtons;
|
2025-09-25 11:09:09 +08:00
|
|
|
|
|
|
|
|
internal void BindHotKeys()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < hotButtons.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
hotButtons[i].BindHotKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void UnBindHotKeys()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < hotButtons.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
hotButtons[i].UnBindHotKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-13 20:20:01 +08:00
|
|
|
|
|
|
|
|
#endif
|