34 lines
958 B
C#
34 lines
958 B
C#
using UnityEngine;
|
|
|
|
public abstract class InputGlyphBehaviourBase : MonoBehaviour
|
|
{
|
|
protected InputDeviceWatcher.InputDeviceCategory CurrentCategory { get; private set; }
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
CurrentCategory = InputDeviceWatcher.CurrentCategory;
|
|
InputDeviceWatcher.OnDeviceContextChanged += HandleDeviceContextChanged;
|
|
InputBindingManager.BindingsChanged += HandleBindingsChanged;
|
|
RefreshGlyph();
|
|
}
|
|
|
|
protected virtual void OnDisable()
|
|
{
|
|
InputDeviceWatcher.OnDeviceContextChanged -= HandleDeviceContextChanged;
|
|
InputBindingManager.BindingsChanged -= HandleBindingsChanged;
|
|
}
|
|
|
|
private void HandleDeviceContextChanged(InputDeviceWatcher.DeviceContext context)
|
|
{
|
|
CurrentCategory = context.Category;
|
|
RefreshGlyph();
|
|
}
|
|
|
|
private void HandleBindingsChanged()
|
|
{
|
|
RefreshGlyph();
|
|
}
|
|
|
|
protected abstract void RefreshGlyph();
|
|
}
|