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

34 lines
922 B
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)
{
CurrentCategory = category;
RefreshGlyph();
}
private void HandleBindingsChanged()
{
RefreshGlyph();
}
protected abstract void RefreshGlyph();
}