Click or drag to resize

SingletonT Class

MonoBehaviours that create just one instance can inherit from this class for global access.
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          KitSingletonT

Namespace:  Kit
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0
Syntax
C#
public class Singleton<T> : MonoBehaviour
where T : MonoBehaviour
Request Example View Source

Type Parameters

T

The SingletonT type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberInstance
Top
Extension Methods
  NameDescription
Public Extension MethodDestroy
Destroy the object.
(Defined by UnityObjectExtensions.)
Public Extension MethodDisable
Set the enabled property to .
(Defined by BehaviourExtensions.)
Public Extension MethodEnable
Set the enabled property to .
(Defined by BehaviourExtensions.)
Public Extension MethodGetBounds

Returns the bounds of the Component.

(Defined by ComponentExtensions.)
Public Extension MethodIsPrefab
Returns whether the Component is a part of a prefab.
(Defined by ComponentExtensions.)
Top
Remarks
Should be used very sparingly as the class uses FindObjectOfType``1 if an instance is not found, which is costly. An over-use of singletons also suggests design issues.
See Also

Reference