Click or drag to resize

SingletonT Class

A class that creates an instance of an object if it doesn't exist, and ensures only one object of that type exists at a time
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          DustProductions.CoreSingletonT
            DustProductions.CoreCursorManager

Namespace:  DustProductions.Core
Assembly:  DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Singleton<T> : MonoBehaviour
where T : MonoBehaviour

Type Parameters

T
The type of the object to create a Singleton of

The SingletonT type exposes the following members.

Constructors
  NameDescription
Public methodSingletonT
Initializes a new instance of the SingletonT class
Top
Properties
  NameDescription
Public propertyStatic memberHasInstance
Checks if there is an instance of this Singleton in this object without creating one
Public propertyStatic memberInstance
Returns the instance of this Singleton, and creates one if it doesn't exist
Public propertyPersistsBetweenLoads
Should this object survive a scene change?
Top
Methods
  NameDescription
Protected methodAwake
This checks for any other Singletons and destroys itself if one exists.
Public methodStatic memberCreateInstance
If you want more control over when Singletons are created, you can use this to generate it instead of blindly calling the .Instance.
Top
Fields
  NameDescription
Protected fieldStatic member_Instance
The backing variable for Instance. Probably should not access this directly.
Top
Extension Methods
  NameDescription
Public Extension MethodAnnounceComponentAdded
Notifies any IComponentHandlers on the GameObject a Component is added to, that the Component has been added.
(Defined by ExtensionMethods.)
Public Extension MethodStartCoroutineT
Use by calling this.StartCoroutine and assigning it to a Coroutine. Then you can call your assigned coroutine.Cancel(), or .HasFinished, or a variety of other neat things.
(Defined by ExtensionMethods.)
Public Extension MethodTryGetComponentT(T, Boolean)Overloaded.
Attempts to get a component on a gameobject.
(Defined by ExtensionMethods.)
Public Extension MethodTryGetComponentT1, T2(T1, Boolean)Overloaded.
Attempts to get a component on a gameobject.
(Defined by ExtensionMethods.)
Public Extension MethodTryGetComponentsT(T, Boolean)Overloaded.
Attempts to get components on a gameobject.
(Defined by ExtensionMethods.)
Public Extension MethodTryGetComponentsT1, T2(T1, Boolean)Overloaded.
Attempts to get components on a gameobject.
(Defined by ExtensionMethods.)
Top
See Also