Singleton<T>


Declaration

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

Description

A singleton behavior that ensures only a single instance of a specified type is instantiated in the scene. The singleton will be destroyed when the scene is unloaded.

Type Parameters

TThe type of component to instantiate.

Static Properties

InstanceThe current instance of the class. The instance will be created if it does not already exist.
HasInstanceChecks if the singleton has been initialized and an instance is available to use.

Methods

SetUpHandles initializing the singleton on Awake. This function should be used in replacement of Awake.
TearDownHandles deinitializing the singleton. This function should be used in replacement of OnDestroy.