docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class RPCHandler

    Main point of access to RPC APIs.

    Inheritance
    object
    RPCHandler
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.Netcode
    Assembly: Unity.NetCode.dll
    Syntax
    public class RPCHandler

    Methods

    Invoke<T>(T, List<Connection>)

    Call to send an RPC of type T to the list of specified connections

    Declaration
    public void Invoke<T>(T RPC, List<Connection> targets) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    T RPC

    The RPC to send

    List<Connection> targets

    The list of connections to send to

    Type Parameters
    Name Description
    T

    The type of the RPC to Invoke.

    Invoke<T>(T, List<NetcodeWorld>, SendDirection)

    Call to send an RPC of type T to the specified worlds, this will find the connection on the worlds

    Declaration
    public void Invoke<T>(T rpc, List<NetcodeWorld> targets, SendDirection direction) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    T rpc

    The RPC to send

    List<NetcodeWorld> targets

    The worlds to send the RPC on all of that worlds connections

    SendDirection direction

    The direction the RPC is intended to be sent

    Type Parameters
    Name Description
    T

    The type of the RPC to Invoke.

    Invoke<T>(T, Connection)

    Call to send an RPC of type T to the specified connection

    Declaration
    public void Invoke<T>(T RPC, Connection target) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    T RPC

    The RPC to send

    Connection target

    The connection to send the RPC on

    Type Parameters
    Name Description
    T

    The type of the RPC to Invoke.

    Invoke<T>(T, NetcodeWorld, SendDirection)

    Call to send an RPC of type T to the specified world, this will find the connection on that world

    Declaration
    public void Invoke<T>(T rpc, NetcodeWorld target, SendDirection direction) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    T rpc

    The RPC to send

    NetcodeWorld target

    The world to send the RPC on all of that worlds connections

    SendDirection direction

    The direction the RPC is intended to be sent

    Type Parameters
    Name Description
    T

    The type of the RPC to Invoke.

    Query<T>()

    Call to get all the RPCs of type T received in all connections on the client and server worlds since the last call of Query.

    Declaration
    public List<T> Query<T>() where T : unmanaged, ICustomMessage
    Returns
    Type Description
    List<T>

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(List<Connection>)

    Call to get all the RPCs of type T received on the specified connections

    Declaration
    public List<T> Query<T>(List<Connection> targets) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    List<Connection> targets

    The list of connections to query for received RPCs

    Returns
    Type Description
    List<T>

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(List<Connection>, List<T>)

    Call to get all the RPCs of type T received on the specified connections

    Declaration
    public void Query<T>(List<Connection> targets, List<T> RPCs) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    List<Connection> targets

    The list of connections to query for received RPCs

    List<T> RPCs

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(List<NetcodeWorld>)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public List<T> Query<T>(List<NetcodeWorld> worlds) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    List<NetcodeWorld> worlds

    The connection to query for received RPCs

    Returns
    Type Description
    List<T>

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(List<NetcodeWorld>, List<T>)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public void Query<T>(List<NetcodeWorld> worlds, List<T> rpcs) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    List<NetcodeWorld> worlds

    The list of worlds to query for received RPCs

    List<T> rpcs

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(List<T>)

    Call to get all the RPCs of type T received in all connections on the client and server worlds since the last call of Query. This will clear the RPCs list before adding to it.

    Declaration
    public void Query<T>(List<T> rpcs) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    List<T> rpcs

    A list of RPCs of type T to set to all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(Connection)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public List<T> Query<T>(Connection target) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    Connection target

    The connection to query for received RPCs

    Returns
    Type Description
    List<T>

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(Connection, List<T>)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public void Query<T>(Connection target, List<T> rpcs) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    Connection target

    The connection to query for received RPCs

    List<T> rpcs

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(NetcodeWorld)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public List<T> Query<T>(NetcodeWorld world) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    NetcodeWorld world

    The world to query for received RPCs

    Returns
    Type Description
    List<T>

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    Query<T>(NetcodeWorld, List<T>)

    Call to get all the RPCs of type T received on the specified connection

    Declaration
    public void Query<T>(NetcodeWorld world, List<T> rpcs) where T : unmanaged, ICustomMessage
    Parameters
    Type Name Description
    NetcodeWorld world

    The world to query for received RPCs

    List<T> rpcs

    A list of all the received RPCs.

    Type Parameters
    Name Description
    T

    The type of the RPC to Query.

    RegisterAutoInvokeType(RPCInvokeID, AutoHandleDelegate, NetcodeWorld)

    Register an RPC handle method with its id so it can be automatically actioned when received

    Declaration
    public void RegisterAutoInvokeType(RPCInvokeID id, RPCHandler.AutoHandleDelegate invokeDelegate, NetcodeWorld world)
    Parameters
    Type Name Description
    RPCInvokeID id

    The id of the RPC

    RPCHandler.AutoHandleDelegate invokeDelegate

    the method to invoke when an RPC with this id is received

    NetcodeWorld world

    the world to be registered into

    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)