logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityEventDispatcherService

    Unity-specific implementation of event dispatcher service using in-memory delegate dictionary.
    Provides type-safe event subscription, unsubscription, and dispatching functionality using EventDispatcherSignal-derived events. Maintains event subscribers in a dictionary keyed by event type and supports both generic and non-generic event dispatching for flexible event-driven architecture integration within Unity applications.

    Inheritance
    object
    UnityEventDispatcherService
    Implements
    IEventDispatcherService
    IService
    IFoundationSettings
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.EventDispatcher.Infrastructure.Services
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public class UnityEventDispatcherService : IEventDispatcherService, IService, IFoundationSettings

    Constructors

    UnityEventDispatcherService()

    Initializes the Unity event dispatcher service with empty event dictionary.
    Creates internal dictionary for storing event type to delegate mappings for subscriber management and event dispatching operations.

    Declaration
    public UnityEventDispatcherService()

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    Dispatch(EventDispatcherSignal, Type)

    Dispatches an event signal using explicit type information for non-generic scenarios.
    Invokes all registered callbacks for the specified event type with the provided signal instance. Supports runtime type resolution when generic type information is not available at compile time. Returns early if no subscribers exist.

    Declaration
    public void Dispatch(EventDispatcherSignal signal, Type type)
    Parameters
    Type Name Description
    EventDispatcherSignal signal

    Event signal instance to dispatch to subscribers

    Type type

    Runtime type information for event signal dispatching

    Dispatch<T>(T)

    Dispatches an event signal to all subscribed callbacks of the specified type.
    Invokes all registered callbacks for the event type with the provided signal instance. Returns early if no subscribers exist for the event type, otherwise executes the entire delegate multicast chain with the signal parameter.

    Declaration
    public void Dispatch<T>(T signal) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    T signal

    Event signal instance to dispatch to subscribers

    Type Parameters
    Name Description
    T

    Event signal type derived from EventDispatcherSignal

    Subscribe<T>(EventDispatcherSignalDelegate)

    Subscribes a callback delegate to receive events of the specified type.
    Registers the callback to be invoked when events of type T are dispatched. Creates new event entry if this is the first subscriber for this event type, otherwise adds the callback to existing delegate multicast chain.

    Declaration
    public void Subscribe<T>(EventDispatcherSignalDelegate callback) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    EventDispatcherSignalDelegate callback

    Delegate callback to invoke when events are dispatched

    Type Parameters
    Name Description
    T

    Event signal type derived from EventDispatcherSignal

    Unsubscribe<T>(EventDispatcherSignalDelegate)

    Unsubscribes a callback delegate from receiving events of the specified type.
    Removes the callback from the delegate multicast chain for the specified event type. If the event type exists in the dictionary, the callback is removed using delegate subtraction operator for clean unsubscription.

    Declaration
    public void Unsubscribe<T>(EventDispatcherSignalDelegate callback) where T : EventDispatcherSignal
    Parameters
    Type Name Description
    EventDispatcherSignalDelegate callback

    Delegate callback to remove from event subscriptions

    Type Parameters
    Name Description
    T

    Event signal type derived from EventDispatcherSignal

    Implements

    IEventDispatcherService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved