docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class MessageAction

    A type-dispatching action map that routes an IMessage to a registered callback based on its MessageTypeId.

    Inheritance
    object
    MessageAction
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.SimulationPro.Foundation
    Assembly: Unity.SimulationPro.Foundation.dll
    Syntax
    public class MessageAction

    Methods

    Add(MessageTypeId, Action<IMessage>)

    Registers a callback for messages with the given MessageTypeId.

    Declaration
    public void Add(MessageTypeId messageTypeName, Action<IMessage> callback)
    Parameters
    Type Name Description
    MessageTypeId messageTypeName

    The message type ID to dispatch on.

    Action<IMessage> callback

    The action to invoke when a matching message is received.

    Add<T>(Action<T>)

    Registers a strongly-typed callback for messages of type T.

    Declaration
    public void Add<T>(Action<T> callback) where T : IMessage
    Parameters
    Type Name Description
    Action<T> callback

    The typed action to invoke when a message of type T is received.

    Type Parameters
    Name Description
    T

    The concrete IMessage type to handle.

    Invoke(IMessage)

    Dispatches the message to the registered callback matching its MessageTypeId.

    Declaration
    public void Invoke(IMessage msg)
    Parameters
    Type Name Description
    IMessage msg

    The message to dispatch.

    Exceptions
    Type Condition
    NotImplementedException

    Thrown if no callback is registered for the message type.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)