AlicizaX/Client/Assets/Scripts/CustomeModule/InputGlyph/InputGlyphBehaviourBase.cs

42 lines
1.2 KiB
C#
Raw Normal View History

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