From 374ca279498e1df0c2e2025350f2eaf172ab5bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Mon, 11 Aug 2025 16:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhotkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/UXComponent/UX/UXHotkey.cs | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Runtime/UXComponent/UX/UXHotkey.cs b/Runtime/UXComponent/UX/UXHotkey.cs index f7d52f0..94d0238 100644 --- a/Runtime/UXComponent/UX/UXHotkey.cs +++ b/Runtime/UXComponent/UX/UXHotkey.cs @@ -109,41 +109,41 @@ internal static class UXHotkeyComponent { if (_hotkeyRegistry.TryGetValue(actionId, out var registrations)) { + HotkeyRegistration hotkeyInfo; for (int i = registrations.Count - 1; i >= 0; i--) { if (registrations[i].button == button) { - registrations.RemoveAt(i); - break; - } - } - - if (registrations.Count == 0) - { - _hotkeyRegistry.Remove(actionId); - - if (_sharedHandlers.TryGetValue(actionId, out var handlerInfo)) - { - var (handler, pressType) = handlerInfo; - var actionRef = registrations.Count > 0 ? registrations[0].reference : null; - - if (actionRef != null && actionRef.action != null) + hotkeyInfo = registrations[i]; + if (_sharedHandlers.TryGetValue(actionId, out var handlerInfo)) { - actionRef.action.Disable(); + var (handler, pressType) = handlerInfo; + var actionRef = hotkeyInfo.reference; - - switch (pressType) + if (actionRef != null && actionRef.action != null) { - case EHotkeyPressType.Started: - actionRef.action.started -= handler; - break; - case EHotkeyPressType.Performed: - actionRef.action.performed -= handler; - break; + if (registrations.Count == 0) + { + actionRef.action.Disable(); + } + + switch (pressType) + { + case EHotkeyPressType.Started: + actionRef.action.started -= handler; + break; + case EHotkeyPressType.Performed: + actionRef.action.performed -= handler; + break; + } } + + _sharedHandlers.Remove(actionId); } - _sharedHandlers.Remove(actionId); + registrations.RemoveAt(i); + _hotkeyRegistry.Remove(actionId); + break; } } }