AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
GamePadHandlerBase.cs
Go to the documentation of this file.
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 }
Input Manager is responsible for managing input sources and dispatching relevant events to the approp...
Definition: InputManager.cs:19
virtual void OnSourceLost(SourceStateEventData eventData)
virtual void OnSourceDetected(SourceStateEventData eventData)
static T Instance
Returns the Singleton instance of the classes type. If no instance is found, then we search for an in...
Definition: Singleton.cs:26
Interface to implement to react to source state changes, such as when an input source is detected or ...
Describes an source state event that has a source id.