修复一个神经bug

This commit is contained in:
陈思海 2025-12-10 11:11:59 +08:00
parent d17eaaaa8b
commit 574ba0df7d
2 changed files with 18 additions and 7 deletions

View File

@ -2,14 +2,15 @@
using System.Collections.Generic;
using System.Reflection;
using AlicizaX.Editor;
using AlicizaX.UI;
using AlicizaX.UI.Runtime;
using UnityEditor;
using UnityEngine;
namespace AlicizaX.UI
namespace AlicizaX.UI111
{
[CustomEditor(typeof(HotkeyBindComponent))]
public class HotkeyBindComponentInspector : GameFrameworkInspector
public class HotkeyBindComponentInspector : UnityEditor.Editor
{
private SerializedProperty hotButtonsProp;
private HotkeyBindComponent _target;
@ -24,7 +25,7 @@ namespace AlicizaX.UI
{
serializedObject.Update();
// 🔸 检查是否缺少 UIHolderObjectBase
var holder = _target.GetComponent<UIHolderObjectBase>();
if (holder == null)
{
@ -98,9 +99,11 @@ namespace AlicizaX.UI
.GetField("hotButtons", BindingFlags.NonPublic | BindingFlags.Instance)
?.SetValue(_target, valiedHotkeys.ToArray());
var collectMethod = target.GetType().GetMethod("CollectUXHotkeys", BindingFlags.NonPublic | BindingFlags.Instance);
collectMethod.Invoke(target, null);
EditorUtility.SetDirty(_target);
serializedObject.Update();
Debug.Log($"[HotkeyBindComponent] 已找到 {uxHotkeys.Length} 个 UXHotkey 组件并绑定。");
}
}

View File

@ -4,7 +4,7 @@ using UnityEngine;
namespace AlicizaX.UI
{
[DisallowMultipleComponent]
// [DisallowMultipleComponent]
public class HotkeyBindComponent : MonoBehaviour
{
private UIHolderObjectBase _holderObjectBase;
@ -21,8 +21,8 @@ namespace AlicizaX.UI
_holderObjectBase.OnWindowShowEvent -= BindHotKeys;
_holderObjectBase.OnWindowClosedEvent -= UnBindHotKeys;
}
[SerializeField]
private UXHotkeyButton[] hotButtons;
[SerializeField] private UXHotkeyButton[] hotButtons;
internal void BindHotKeys()
{
@ -32,6 +32,14 @@ namespace AlicizaX.UI
}
}
#if UNITY_EDITOR
[ContextMenu("Bind HotKeys")]
private void CollectUXHotkeys()
{
hotButtons = gameObject.GetComponentsInChildren<UXHotkeyButton>(true);
}
#endif
internal void UnBindHotKeys()
{
for (int i = 0; i < hotButtons.Length; i++)