2026-03-17 20:02:47 +08:00
|
|
|
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;
|
2026-03-17 20:02:47 +08:00
|
|
|
InputBindingManager.BindingsChanged += HandleBindingsChanged;
|
|
|
|
|
RefreshGlyph();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void OnDisable()
|
|
|
|
|
{
|
2026-03-17 20:08:19 +08:00
|
|
|
InputDeviceWatcher.OnDeviceChanged -= HandleDeviceChanged;
|
2026-03-17 20:02:47 +08:00
|
|
|
InputBindingManager.BindingsChanged -= HandleBindingsChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 20:08:19 +08:00
|
|
|
private void HandleDeviceChanged(InputDeviceWatcher.InputDeviceCategory category)
|
2026-03-17 20:02:47 +08:00
|
|
|
{
|
2026-03-20 13:51:22 +08:00
|
|
|
InputDeviceWatcher.InputDeviceCategory previousCategory = CurrentCategory;
|
2026-03-17 20:08:19 +08:00
|
|
|
CurrentCategory = category;
|
2026-03-20 13:51:22 +08:00
|
|
|
OnDeviceCategoryChanged(previousCategory, category);
|
2026-03-17 20:02:47 +08:00
|
|
|
RefreshGlyph();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleBindingsChanged()
|
|
|
|
|
{
|
|
|
|
|
RefreshGlyph();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 13:51:22 +08:00
|
|
|
protected virtual void OnDeviceCategoryChanged(
|
|
|
|
|
InputDeviceWatcher.InputDeviceCategory previousCategory,
|
|
|
|
|
InputDeviceWatcher.InputDeviceCategory newCategory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-17 20:02:47 +08:00
|
|
|
protected abstract void RefreshGlyph();
|
|
|
|
|
}
|