Table of Contents

Class Singleton<T>

Utility class to make inheriting types singletons.

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

Type Parameters

T

The type to be made a singleton.

Inheritance
System.Object
Singleton<T>

Properties

HasInstance

Is there an existing instance of type T?

public static bool HasInstance { get; }

Property Value

bool

Remarks

If there is no set instance, this will try to find them. If more than one instance is found, the extra instances are deleted.

Instance

The active instance of type T.

public static T Instance { get; }

Property Value

T

Remarks

If there is no set instance, this will try to find them. If more than one instance is found, the extra instances are deleted. If none are found, a new instance is created.