AlicizaX/Client/Assets/Scripts/CustomeModule/InputGlyph/InputGlyphBehaviourBase.cs
陈思海 7a4d51f17c 优化
1.InputGlyph组件绑定整合
2.自动分析复合引用 动态切换绑定类型 移除旧的复杂多组件
3.增加热键测试
2026-03-20 13:51:22 +08:00

42 lines
1.2 KiB
C#

using UnityEngine;
public abstract class InputGlyphBehaviourBase : MonoBehaviour
{
protected InputDeviceWatcher.InputDeviceCategory CurrentCategory { get; private set; }
protected virtual void OnEnable()
{
CurrentCategory = InputDeviceWatcher.CurrentCategory;
InputDeviceWatcher.OnDeviceChanged += HandleDeviceChanged;
InputBindingManager.BindingsChanged += HandleBindingsChanged;
RefreshGlyph();
}
protected virtual void OnDisable()
{
InputDeviceWatcher.OnDeviceChanged -= HandleDeviceChanged;
InputBindingManager.BindingsChanged -= HandleBindingsChanged;
}
private void HandleDeviceChanged(InputDeviceWatcher.InputDeviceCategory category)
{
InputDeviceWatcher.InputDeviceCategory previousCategory = CurrentCategory;
CurrentCategory = category;
OnDeviceCategoryChanged(previousCategory, category);
RefreshGlyph();
}
private void HandleBindingsChanged()
{
RefreshGlyph();
}
protected virtual void OnDeviceCategoryChanged(
InputDeviceWatcher.InputDeviceCategory previousCategory,
InputDeviceWatcher.InputDeviceCategory newCategory)
{
}
protected abstract void RefreshGlyph();
}