Interface ICommandDataSerializer<T>
Interface that must be implemented to serialize/deserialize ICommand
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
public interface ICommandDataSerializer<T> where T : unmanaged, ICommandData
Type Parameters
Name | Description |
---|---|
T | Your data type. |
Methods
CalculateChangeMask(in T, in T)
Used to delta-compress this command when sending it via the
Command
Declaration
uint CalculateChangeMask(in T snapshot, in T baseline)
Parameters
Type | Name | Description |
---|---|---|
T | snapshot | The current value. |
T | baseline | The previous/baseline value. |
Returns
Type | Description |
---|---|
uint | A change-mask, 0 if unchanged. |
Remarks
The default interface implementation (maintained for non-breaking change backwards compatibility) always returns 1 (has changes), so we strongly recommend overriding it in your own implementation (assuming your implementing this interface yourself). The automatic code-generated version uses a per-field change mask automatically.
Deserialize(ref DataStreamReader, in RpcDeserializerState, ref T)
Deserialize a single command from the data stream.
Declaration
void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state, ref T data)
Parameters
Type | Name | Description |
---|---|---|
Data |
reader | An instance of a Data |
Rpc |
state | An instance of Rpc |
T | data | Command |
Deserialize(ref DataStreamReader, in RpcDeserializerState, ref T, in T, StreamCompressionModel)
Deserialize a single command from the data stream using delta compression
Declaration
void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state, ref T data, in T baseline, StreamCompressionModel compressionModel)
Parameters
Type | Name | Description |
---|---|---|
Data |
reader | An instance of a Data |
Rpc |
state | An instance of Rpc |
T | data | Command |
T | baseline | Baseline command |
Stream |
compressionModel | Delta compression model |
Serialize(ref DataStreamWriter, in RpcSerializerState, in T)
Serialize the command to the data stream.
Declaration
void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in T data)
Parameters
Type | Name | Description |
---|---|---|
Data |
writer | An instance of a Data |
Rpc |
state | An instance of Rpc |
T | data | Command |
Serialize(ref DataStreamWriter, in RpcSerializerState, in T, in T, StreamCompressionModel)
Serialize the command to the data stream using delta compression.
Declaration
void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in T data, in T baseline, StreamCompressionModel compressionModel)
Parameters
Type | Name | Description |
---|---|---|
Data |
writer | An instance of a Data |
Rpc |
state | An instance of Rpc |
T | data | Command |
T | baseline | Baseline command |
Stream |
compressionModel | Delta compression model |
ToFixedString()
Helper.
Declaration
FixedString64Bytes ToFixedString()
Returns
Type | Description |
---|---|
Fixed |
A short name, for use in packet dumps. |