Search Results for

    Show / Hide Table of Contents

    Class Service<T>

    A Service is a singleton MonoBehaviour with certain capibilities in Unity.

    Inheritance
    Object
    UnityEngine.Object
    UnityEngine.Component
    UnityEngine.Behaviour
    UnityEngine.MonoBehaviour
    NoSuchMonoBehaviour
    Service<T>
    Inherited Members
    NoSuchMonoBehaviour.logger
    NoSuchMonoBehaviour.loggerConfig
    NoSuchMonoBehaviour.LogLogFormat(String, Object[])
    NoSuchMonoBehaviour.LogLog(String)
    NoSuchMonoBehaviour.LogWarnFormat(String, Object[])
    NoSuchMonoBehaviour.LogWarn(String)
    NoSuchMonoBehaviour.LogErrorFormat(String, Object[])
    NoSuchMonoBehaviour.LogError(String)
    NoSuchMonoBehaviour.LogLogFormat<T>(String, Object[])
    NoSuchMonoBehaviour.LogLog<T>(String)
    NoSuchMonoBehaviour.LogWarnFormat<T>(String, Object[])
    NoSuchMonoBehaviour.LogWarn<T>(String)
    NoSuchMonoBehaviour.LogErrorFormat<T>(String, Object[])
    NoSuchMonoBehaviour.LogError<T>(String)
    NoSuchMonoBehaviour.LogLogFormat<T>(Object, String, Object[])
    NoSuchMonoBehaviour.LogLog<T>(Object, String)
    NoSuchMonoBehaviour.LogWarnFormat<T>(Object, String, Object[])
    NoSuchMonoBehaviour.LogWarn<T>(Object, String)
    NoSuchMonoBehaviour.LogErrorFormat<T>(Object, String, Object[])
    NoSuchMonoBehaviour.LogError<T>(Object, String)
    NoSuchMonoBehaviour.RunDelayed(Single, Action)
    NoSuchMonoBehaviour.RunDelayedRealtime(Single, Action)
    NoSuchMonoBehaviour.RunPeriodic(Single, Action)
    NoSuchMonoBehaviour.RunPeriodicRealtime(Single, Action)
    NoSuchMonoBehaviour.RunWhile(Single, Func<Boolean>, Action)
    NoSuchMonoBehaviour.RunWhileRealtime(Single, Func<Boolean>, Action)
    Namespace: NoSuchStudio.Common.Service
    Assembly: NoSuchStudio-Common.dll
    Syntax
    public abstract class Service<T> : NoSuchMonoBehaviour where T : Service<T>
    Type Parameters
    Name Description
    T
    Remarks

    This class serves as a singleton for Unity. A Service:

    • Ensures there is at most one Instance of the MonoBehaviour Active at any given point in time. If another Intance becomes Active, the old one will go offline.
    • Provides a static API surface through the currently Active Instance. Individual services can provide fallback methods in cases there is no Instance for the service.
    • Will find all Components that use it in the Scene initially and connects them. IServiceComponent<T>

    Fields

    _instanceReady

    Declaration
    protected bool _instanceReady
    Field Value
    Type Description
    Boolean

    gInstance

    The global instance of this NoSuchStudio.Common.Service. For normal usage, use RegisterInstance(T) and UnregisterInstance(T).

    Declaration
    protected static T gInstance
    Field Value
    Type Description
    T

    needsEditorRepaint

    Declaration
    [NonSerialized]
    public bool needsEditorRepaint
    Field Value
    Type Description
    Boolean

    Properties

    Instance

    The property for accessing the global instance of this NoSuchStudio.Common.Service. For normal usage, use RegisterInstance(T) and UnregisterInstance(T).

    Declaration
    public static T Instance { get; protected set; }
    Property Value
    Type Description
    T

    InstanceReady

    Declaration
    public bool InstanceReady { get; }
    Property Value
    Type Description
    Boolean

    IsInstance

    Checks if the current instance is the global instance.

    Declaration
    public bool IsInstance { get; }
    Property Value
    Type Description
    Boolean

    IsReady

    Returns true if this Service has an Active Instance and can be used.
    Declaration
    public static bool IsReady { get; }
    Property Value
    Type Description
    Boolean

    Methods

    OnDisable()

    Declaration
    protected virtual void OnDisable()

    OnEnable()

    Declaration
    protected virtual void OnEnable()

    OnServiceRegister()

    Callback for when an instance becomes the global instance.

    Declaration
    public virtual void OnServiceRegister()

    OnServiceUnregister()

    Callback for when an instance is no longer the global instance.

    Declaration
    public virtual void OnServiceUnregister()

    RegisterInstance(T)

    Service instances call this OnEnable to become the global instance.

    Declaration
    protected static void RegisterInstance(T instance)
    Parameters
    Type Name Description
    T instance

    ReRegisterService()

    Same effect as disabling and enabling the service instance.

    Declaration
    public void ReRegisterService()

    UnregisterInstance(T)

    Service instances call this OnDisable to release the global instance.

    Declaration
    protected static void UnregisterInstance(T instance)
    Parameters
    Type Name Description
    T instance

    Extension Methods

    MonoBehaviourRunExt.RunDelayed(MonoBehaviour, Single, Action)
    MonoBehaviourRunExt.RunDelayedRealtime(MonoBehaviour, Single, Action)
    MonoBehaviourRunExt.RunPeriodic(MonoBehaviour, Single, Action)
    MonoBehaviourRunExt.RunPeriodicRealtime(MonoBehaviour, Single, Action)
    MonoBehaviourRunExt.RunWhile(MonoBehaviour, Single, Func<Boolean>, Action)
    MonoBehaviourRunExt.RunWhileRealtime(MonoBehaviour, Single, Func<Boolean>, Action)
    UnityObjectLoggerExt.LogLogFormat(Object, String, Object[])
    UnityObjectLoggerExt.LogLog(Object, String)
    UnityObjectLoggerExt.LogWarnFormat(Object, String, Object[])
    UnityObjectLoggerExt.LogWarn(Object, String)
    UnityObjectLoggerExt.LogErrorFormat(Object, String, Object[])
    UnityObjectLoggerExt.LogError(Object, String)
    In This Article
    Back to top Generated by DocFX