修复一个神经bug
This commit is contained in:
parent
d17eaaaa8b
commit
574ba0df7d
@ -2,14 +2,15 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using AlicizaX.Editor;
|
using AlicizaX.Editor;
|
||||||
|
using AlicizaX.UI;
|
||||||
using AlicizaX.UI.Runtime;
|
using AlicizaX.UI.Runtime;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.UI
|
namespace AlicizaX.UI111
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(HotkeyBindComponent))]
|
[CustomEditor(typeof(HotkeyBindComponent))]
|
||||||
public class HotkeyBindComponentInspector : GameFrameworkInspector
|
public class HotkeyBindComponentInspector : UnityEditor.Editor
|
||||||
{
|
{
|
||||||
private SerializedProperty hotButtonsProp;
|
private SerializedProperty hotButtonsProp;
|
||||||
private HotkeyBindComponent _target;
|
private HotkeyBindComponent _target;
|
||||||
@ -24,7 +25,7 @@ namespace AlicizaX.UI
|
|||||||
{
|
{
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
// 🔸 检查是否缺少 UIHolderObjectBase
|
|
||||||
var holder = _target.GetComponent<UIHolderObjectBase>();
|
var holder = _target.GetComponent<UIHolderObjectBase>();
|
||||||
if (holder == null)
|
if (holder == null)
|
||||||
{
|
{
|
||||||
@ -98,9 +99,11 @@ namespace AlicizaX.UI
|
|||||||
.GetField("hotButtons", BindingFlags.NonPublic | BindingFlags.Instance)
|
.GetField("hotButtons", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||||
?.SetValue(_target, valiedHotkeys.ToArray());
|
?.SetValue(_target, valiedHotkeys.ToArray());
|
||||||
|
|
||||||
|
var collectMethod = target.GetType().GetMethod("CollectUXHotkeys", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
collectMethod.Invoke(target, null);
|
||||||
|
|
||||||
EditorUtility.SetDirty(_target);
|
EditorUtility.SetDirty(_target);
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
Debug.Log($"[HotkeyBindComponent] 已找到 {uxHotkeys.Length} 个 UXHotkey 组件并绑定。");
|
Debug.Log($"[HotkeyBindComponent] 已找到 {uxHotkeys.Length} 个 UXHotkey 组件并绑定。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AlicizaX.UI
|
namespace AlicizaX.UI
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
// [DisallowMultipleComponent]
|
||||||
public class HotkeyBindComponent : MonoBehaviour
|
public class HotkeyBindComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private UIHolderObjectBase _holderObjectBase;
|
private UIHolderObjectBase _holderObjectBase;
|
||||||
@ -21,8 +21,8 @@ namespace AlicizaX.UI
|
|||||||
_holderObjectBase.OnWindowShowEvent -= BindHotKeys;
|
_holderObjectBase.OnWindowShowEvent -= BindHotKeys;
|
||||||
_holderObjectBase.OnWindowClosedEvent -= UnBindHotKeys;
|
_holderObjectBase.OnWindowClosedEvent -= UnBindHotKeys;
|
||||||
}
|
}
|
||||||
[SerializeField]
|
|
||||||
private UXHotkeyButton[] hotButtons;
|
[SerializeField] private UXHotkeyButton[] hotButtons;
|
||||||
|
|
||||||
internal void BindHotKeys()
|
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()
|
internal void UnBindHotKeys()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < hotButtons.Length; i++)
|
for (int i = 0; i < hotButtons.Length; i++)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user