FAST SDK Coding Reference 1.0.3
Loading...
Searching...
No Matches
Singleton< T > Class Template Referenceabstract

A simple singleton pattern for classes that inherit from MonoBehaviour without public access to the instance. More...

Inheritance diagram for Singleton< T >:
Application SingletonWithInstance< T >

Public Attributes

bool dontDestroyOnLoad = false
 Inspector
Set to true if this GameObject should not be destroyed when loading a new scene.
 

Protected Member Functions

virtual void Awake ()
 Sets FAST.Singleton<T>._instance and destorys any additional instances.
 
virtual void OnDestroy ()
 Sets FAST.Singleton<T>._instance to null when the last instance is destroyed.
 

Static Protected Attributes

static T _instance
 Reference to the singleton instance.
 

Detailed Description

A simple singleton pattern for classes that inherit from MonoBehaviour without public access to the instance.

This implementation is not thread-safe.

Template Parameters
TThe type of the derived class.
See also
UnityEngine.MonoBehaviour
UnityEngine.GameObject
Type Constraints
T :Singleton<T> 

Member Function Documentation

◆ Awake()

virtual void Awake ( )
protectedvirtual

Sets FAST.Singleton<T>._instance and destorys any additional instances.

Reimplemented in Application.

◆ OnDestroy()

virtual void OnDestroy ( )
protectedvirtual

Sets FAST.Singleton<T>._instance to null when the last instance is destroyed.

Member Data Documentation

◆ _instance

T _instance
staticprotected

Reference to the singleton instance.

◆ dontDestroyOnLoad

bool dontDestroyOnLoad = false

Inspector
Set to true if this GameObject should not be destroyed when loading a new scene.


The documentation for this class was generated from the following file: