45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
#if INPUTSYSTEM_SUPPORT
|
|
using AlicizaX.UI.Runtime;
|
|
using UnityEngine;
|
|
|
|
namespace AlicizaX.UI.Extension.UXComponent.Hotkey
|
|
{
|
|
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]
|
|
private UXHotkey[] hotButtons;
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|