docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class FuncFromMessage<TResult>

    A type-dispatching function map that derives a TResult from an IMessage, routing to a registered function based on the message's MessageTypeId.

    Inheritance
    object
    FuncFromMessage<TResult>
    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 FuncFromMessage<TResult>
    Type Parameters
    Name Description
    TResult

    The return type produced by each registered function.

    Methods

    Add(MessageTypeId, Func<IMessage, TResult>)

    Registers a function for the given MessageTypeId.

    Declaration
    public void Add(MessageTypeId messageTypeId, Func<IMessage, TResult> callback)
    Parameters
    Type Name Description
    MessageTypeId messageTypeId

    The message type ID to dispatch on.

    Func<IMessage, TResult> callback

    The function that produces a result from an IMessage.

    Add<T>(Func<T, TResult>)

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

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

    The typed function invoked 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 function and returns the result.

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

    The message to dispatch.

    Returns
    Type Description
    TResult

    The result produced by the registered function.

    Exceptions
    Type Condition
    NotImplementedException

    Thrown if no function 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)