This commit is contained in:
陈思海 2025-12-22 10:50:18 +08:00
parent 1f53bf8be4
commit 8a0a2b1a00

View File

@ -44,17 +44,14 @@ namespace UnityEngine.UI
[ContextMenu("Bind HotKeys")]
private void CollectUXHotkeys()
{
// 更稳健的查找:先拿所有 MonoBehaviour再 OfType 接口
var found = gameObject
.GetComponentsInChildren<MonoBehaviour>(true)
.OfType<IHotkeyTrigger>()
.Where(t => t.HotkeyAction != null) // 保留原来的筛选条件(如果 HotkeyAction 存在)
.Where(t => t.HotkeyAction != null)
.Select(t => t as Component)
.ToArray();
hotButtons = found;
Debug.Log($"[HotkeyBindComponent] 已找到 {hotButtons.Length} 个 UXHotkey 组件并绑定。");
}
private void OnValidate()