Newer
Older
HoloAnatomy / Assets / HoloToolkit / Input / Scripts / GamePad / GamePadHandlerBase.cs
SURFACEBOOK2\jackwynne on 25 May 2018 1 KB v1
  1. using UnityEngine;
  2.  
  3. namespace HoloToolkit.Unity.InputModule
  4. {
  5. public class GamePadHandlerBase : MonoBehaviour, ISourceStateHandler
  6. {
  7. [SerializeField]
  8. [Tooltip("True, if gaze is not required for Input")]
  9. protected bool IsGlobalListener = true;
  10.  
  11. protected string GamePadName = string.Empty;
  12.  
  13. private void OnEnable()
  14. {
  15. if (IsGlobalListener)
  16. {
  17. InputManager.Instance.AddGlobalListener(gameObject);
  18. }
  19. }
  20.  
  21. protected virtual void OnDisable()
  22. {
  23. if (IsGlobalListener && InputManager.Instance != null)
  24. {
  25. InputManager.Instance.RemoveGlobalListener(gameObject);
  26. }
  27. }
  28.  
  29. public virtual void OnSourceDetected(SourceStateEventData eventData)
  30. {
  31. // Override and name your GamePad source.
  32. }
  33.  
  34. public virtual void OnSourceLost(SourceStateEventData eventData)
  35. {
  36. GamePadName = string.Empty;
  37. }
  38. }
  39. }