com.alicizax.unity.ui.exten.../Runtime/UXComponent/Hotkey/HotkeyBindComponent.cs
陈思海 d17eaaaa8b opt
修改命名空间
2025-12-09 20:30:11 +08:00

46 lines
1.1 KiB
C#

#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<UIHolderObjectBase>();
_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();
}
}
internal void UnBindHotKeys()
{
for (int i = 0; i < hotButtons.Length; i++)
{
hotButtons[i].UnBindHotKey();
}
}
}
}
#endif