{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Interface IRpcCommandSerializer<T> | Netcode for Entities | 1.1.0-pre.3
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IRpcCommandSerializer<T>

    Interface that must be implemented by a burst-compatible struct to serialize/deserialize the specified rpc type.

    A common pattern is to make the struct declaring the rpc to also implement the serialize/deserialize interface. For example:

    struct MyRpc : IComponentData, IRpcCommandSerializer{MyRpc}
       {
           public void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in MyRpc data)
           { ... }
           public void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state, ref MyRpc data)
           { ... }
           PortableFunctionPointer{RpcExecutor.ExecuteDelegate} CompileExecute()
           { ... }
       }
    When declaring an rpc using the IRpcCommand interface, it is not necessary to implement the `IRpcCommandSerializer` interface yourself; the code-generation will automatically create a struct implementing the interface and all necessary boilerplate code.
    Namespace: Unity.NetCode
    Assembly: solution.dll
    Syntax
    public interface IRpcCommandSerializer<T> where T : struct, IComponentData
    Type Parameters
    Name Description
    T

    Methods

    Name Description
    CompileExecute()

    Invoked when the rpc is registered to the RpcSystem at runtime. Should return a valid burst-compatible function pointer of a static method that will be called after the rpc has been deserialized to actually "execute" the command. By declaring rpcs using IRpcCommand, this method is automatically generated. See also RpcExecutor for further information on how to use it to implement your custom execute method.

    Deserialize(ref DataStreamReader, in RpcDeserializerState, ref T)

    Method called by the RpcSystem when an rpc is dequeued from the IncomingRpcDataStreamBuffer. Copies the data from the reader to the output data. The deserialization code is automatically generated when your struct implements the IRpcCommand interface. You must implement this method yourself when you opt-in for manual serialization.

    Serialize(ref DataStreamWriter, in RpcSerializerState, in T)

    Method called by the RpcSystem when an rpc is dequeued from the OutgoingRpcDataStreamBuffer (to be sent over the network). The serialization code is automatically generated when your struct implements the IRpcCommand interface. You must implement this method yourself when you opt-in for manual serialization.

    In This Article
    Back to top
    Copyright © 2023 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)