NEEDSIM3rdParty.Singleton< T > Class Template Reference

Be aware this will not prevent a non singleton constructor such as T myT = new T(); To prevent that, add protected T () {} to your singleton class. More...

Inherits MonoBehaviour.

Public Member Functions

void OnDestroy ()
 When Unity quits, it destroys objects in a random order. In principle, a Singleton is only destroyed when application quits. If any script calls Instance after it have been destroyed, it will create a buggy ghost object that will stay on the Editor scene even after stopping playing the Application. Really bad! So, this was made to be sure we're not creating that buggy ghost object. More...
 

Detailed Description

Be aware this will not prevent a non singleton constructor such as T myT = new T(); To prevent that, add protected T () {} to your singleton class.

As a note, this is made as MonoBehaviour because we need Coroutines.

Type Constraints
T :MonoBehaviour 

Member Function Documentation

void NEEDSIM3rdParty.Singleton< T >.OnDestroy ( )

When Unity quits, it destroys objects in a random order. In principle, a Singleton is only destroyed when application quits. If any script calls Instance after it have been destroyed, it will create a buggy ghost object that will stay on the Editor scene even after stopping playing the Application. Really bad! So, this was made to be sure we're not creating that buggy ghost object.


The documentation for this class was generated from the following file:
  • Singleton.cs