AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
Timer.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 namespace HoloToolkit.Unity
5 {
9  public struct Timer
10  {
11  public int Id;
12 
13  public static Timer Invalid = new Timer(0);
14 
15  public Timer(int id)
16  {
17  Id = id;
18  }
19 
20  public bool IsActive
21  {
22  get
23  {
24  return (Id != Invalid.Id) && TimerScheduler.Instance.IsTimerActive(this);
25  }
26  }
27 
28  public static Timer Start(float timeSeconds, TimerScheduler.Callback callback, bool loop = false)
29  {
31  {
32  return TimerScheduler.Instance.StartTimer(timeSeconds, callback, loop);
33  }
34 
35  return Invalid;
36  }
37 
38  public static Timer StartNextFrame(TimerScheduler.Callback callback)
39  {
41  {
42  return TimerScheduler.Instance.StartTimer(0.0f, callback, false, true);
43  }
44 
45  return Invalid;
46  }
47 
48  public void Stop()
49  {
51  {
52  TimerScheduler.Instance.StopTimer(this);
53  Id = Invalid.Id;
54  }
55  }
56  }
57 }
A scheduler that manages various timers.
Structure that defines a timer. A timer can be scheduled through the TimerScheduler.
Definition: Timer.cs:9
static Timer Start(float timeSeconds, TimerScheduler.Callback callback, bool loop=false)
Definition: Timer.cs:28
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
static Timer StartNextFrame(TimerScheduler.Callback callback)
Definition: Timer.cs:38
static bool IsInitialized
Returns whether the instance has been initialized or not.
Definition: Singleton.cs:58