Newer
Older
HoloAnatomy / Assets / HoloToolkit / Input / Scripts / GamePad / GamePadHandlerBase.cs
SURFACEBOOK2\jackwynne on 25 May 2018 1 KB v1
using UnityEngine;

namespace HoloToolkit.Unity.InputModule
{
    public class GamePadHandlerBase : MonoBehaviour, ISourceStateHandler
    {
        [SerializeField]
        [Tooltip("True, if gaze is not required for Input")]
        protected bool IsGlobalListener = true;

        protected string GamePadName = string.Empty;

        private void OnEnable()
        {
            if (IsGlobalListener)
            {
                InputManager.Instance.AddGlobalListener(gameObject);
            }
        }

        protected virtual void OnDisable()
        {
            if (IsGlobalListener && InputManager.Instance != null)
            {
                InputManager.Instance.RemoveGlobalListener(gameObject);
            }
        }

        public virtual void OnSourceDetected(SourceStateEventData eventData)
        {
            // Override and name your GamePad source.
        }

        public virtual void OnSourceLost(SourceStateEventData eventData)
        {
            GamePadName = string.Empty;
        }
    }
}