Table of Contents

Class Singleton<T>

Utility class to make inheriting types singletons.

public abstract class Singleton<T> : MonoBehaviour where T : Singleton<T>

Type Parameters

T

The type to be made a singleton.

Inheritance
System.Object
Singleton<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.