AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
StartAwareSingleton.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;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity
8 {
12  [Obsolete]
13  public abstract class StartAwareSingleton<T> : Singleton<T>
14  where T : StartAwareSingleton<T>
15  {
16  #region MonoBehaviour implementation
17 
18  protected virtual void OnEnable()
19  {
20  if (IsStarted)
21  {
22  OnEnableAfterStart();
23  }
24  }
25 
26  protected virtual void OnDisable()
27  {
28  if (IsStarted)
29  {
30  OnDisableAfterStart();
31  }
32  }
33 
34  protected virtual void Start()
35  {
36  IsStarted = true;
37  OnEnableAfterStart();
38  }
39 
40  #endregion
41 
42  protected bool IsStarted { get; private set; }
43 
49  protected virtual void OnEnableAfterStart()
50  {
51  Debug.Assert(IsStarted, "OnEnableAfterStart should only occur after Start.");
52  }
53 
59  protected virtual void OnDisableAfterStart()
60  {
61  Debug.Assert(IsStarted, "OnDisableAfterStart should only occur after Start.");
62  }
63  }
64 }
virtual void OnEnableAfterStart()
This method is similar to Unity&#39;s OnEnable method, except that it&#39;s called only after Start...
virtual void OnDisableAfterStart()
This method is similar to Unity&#39;s OnDisable method, except that it&#39;s called only after Start...
A singleton designed to help child singletons take certain actions only after Start has been called...
Singleton behaviour class, used for components that should only have one instance.
Definition: Singleton.cs:14