com.alicizax.unity.ui.exten.../Runtime/UXComponent/Hotkey/UXHotkey.cs

30 lines
679 B
C#
Raw Normal View History

2025-08-08 16:25:09 +08:00
#if INPUTSYSTEM_SUPPORT
2025-10-13 20:20:01 +08:00
using System;
2025-08-08 16:25:09 +08:00
using UnityEngine;
2025-10-13 20:20:01 +08:00
namespace AlicizaX.UI.Extension
2025-08-08 16:25:09 +08:00
{
2025-10-22 15:24:47 +08:00
[DisallowMultipleComponent]
2025-10-13 20:20:01 +08:00
public class UXHotkey : MonoBehaviour
2025-08-08 16:25:09 +08:00
{
2025-10-13 20:20:01 +08:00
[SerializeField] private UXButton _button;
2025-08-08 16:25:09 +08:00
2025-10-13 20:20:01 +08:00
[SerializeField] internal UnityEngine.InputSystem.InputActionReference _hotKeyRefrence;
[SerializeField] internal EHotkeyPressType _hotkeyPressType;
2025-08-08 16:25:09 +08:00
2025-10-13 20:20:01 +08:00
private void OnValidate()
2025-08-08 16:25:09 +08:00
{
2025-10-13 20:20:01 +08:00
_button = GetComponent<UXButton>();
2025-08-08 16:25:09 +08:00
}
2025-10-13 20:20:01 +08:00
internal void HotkeyActionTrigger()
2025-08-08 16:25:09 +08:00
{
2025-10-13 20:20:01 +08:00
if (_button.Interactable)
2025-08-08 16:25:09 +08:00
{
2025-10-13 20:20:01 +08:00
_button.OnSubmit(null);
2025-08-08 16:25:09 +08:00
}
}
}
}
#endif