SuperBehaviour SuperBehaviour
SuperBehaviour SuperBehaviour
v0.1.2 [Beta]

Search Results for

    Class SingletonBehaviour<T>

    Namespace
    LoM.Super
    Assembly
    LoM.Super.dll

    A singleton MonoBehaviour that inherits from SuperBehaviour.
    Implements a thread-safe singleton pattern as a inheritable base class.


    To create a singleton MonoBehaviour, simply inherit from SingletonBehaviour and add the generic type parameter of the class itself.
    public class GameManager : SingletonBehaviour<GameManager> 
    {
       // ...
    }
    For a hierarchy of singleton classes, use a generic type parameter T in the base class and inherit from SingletonBehaviour.
    This approach ensures that each subclass (GameManager, UIManager, etc.) functions as a singleton, inheriting the singleton behavior from the base Manager class.
    // Base class with generic type parameter T for singleton management
    public class Manager<T> : SingletonBehaviour<T> where T : SuperBehaviour { }
    // Derived singleton classes
    public class GameManager : Manager<GameManager> { }
    public class UIManager : Manager<UIManager> { }

    public class SingletonBehaviour<T> : SuperBehaviour where T : SuperBehaviour

    Type Parameters

    T

    The type of the class to use for the singleton.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SuperBehaviour
    SingletonBehaviour<T>
    Derived
    LazySingletonBehaviour<T>
    Inherited Members
    SuperBehaviour.ShowProperties
    SuperBehaviour.transform
    SuperBehaviour.gameObject
    SuperBehaviour.rectTransform
    SuperBehaviour.IsDestroyed

    Fields

    s_instance

    protected static T s_instance

    Field Value

    T

    s_lock

    protected static readonly object s_lock

    Field Value

    object

    Properties

    Exists

    Returns if Instance is not null.

    public static bool Exists { get; }

    Property Value

    bool

    Instance

    The singleton instance of this class.

    public static T Instance { get; }

    Property Value

    T

    Methods

    AfterAwake()

    Override this method to do something after singleton Awake() is called.

    protected virtual void AfterAwake()

    OnAfterDestroy()

    Override this method to do something after singleton OnDestroy() is called.

    protected virtual void OnAfterDestroy()
    © Lords of Mahlstrom Gaming, all rights reserved.