Class Singleton<T>
Utility class to make inheriting types singletons.
public abstract class Singleton<T> : MonoBehaviour where T : Singleton<T>
Type Parameters
TThe type to be made a singleton.
- Inheritance
-
System.ObjectSingleton<T>
Remarks
Assumes complete ownership of the parent GameObject.
Properties
HasInstance
Is there an existing instance of type T?
public static bool HasInstance { get; }
Property Value
- bool
Instance
The singleton instance of type T.
public static T Instance { get; }
Property Value
- T
Methods
Awake()
protected virtual void Awake()
Remarks
If there is no singleton instance of T, sets it to this,
otherwise, destroys the current GameObject. All inheriting classes must
invoke this method if overriding it.