AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ButtonTimedWaiter.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using System.Collections;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.InputModule.Tests
8 {
9  public class ButtonTimedWaiter : MonoBehaviour
10  {
11  [SerializeField]
12  private TestButton button = null;
13 
14  [SerializeField]
15  private float TimeToWait = 1.0f;
16 
17  [SerializeField]
18  private TextMesh textMesh = null;
19 
20  private void Awake()
21  {
22  button.Activated += OnButtonPressed;
23  }
24 
25  private void OnDisable()
26  {
27  button.Activated -= OnButtonPressed;
28  }
29 
30  private void OnButtonPressed(TestButton source)
31  {
32  InputManager.Instance.PushInputDisable();
33  StartCoroutine(WaitForTime(TimeToWait));
34  }
35 
36  IEnumerator WaitForTime(float timeToWait)
37  {
38  float currentTime = 0.0f;
39 
40  while (currentTime <= timeToWait)
41  {
42  currentTime += Time.deltaTime;
43  textMesh.text = ((currentTime / timeToWait) * 100.0f).ToString("F0") + "%";
44  yield return null;
45  }
46 
47  InputManager.Instance.PopInputDisable();
48  button.Selected = false;
49  textMesh.text = "Wait";
50 
51  yield break;
52  }
53  }
54 }
Input Manager is responsible for managing input sources and dispatching relevant events to the approp...
Definition: InputManager.cs:19
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
Test button that can be added to any object to make it gaze interactable and receive pressed and rele...
Definition: TestButton.cs:13