Hi,
I am using the new netcode of Unity but there is something I don’t understand using IRpcCommandSerializer interface.
The interface provide us the Serialize() and Deserialize() method and the 2nd argument is the RPC itself. But why the Unity team decided to do it this way ? The thing I don’t undertsand is that they don’t use directly the base RPC instead of the argument.
For example
public void Serialize(ref DataStreamWriter writer)
{
writer.WriteInt(intData);
writer.WriteShort(shortData);
}
Instead of
public void Serialize(ref DataStreamWriter writer, in OurDataRpcCommand data)
{
writer.WriteInt(data.intData);
writer.WriteShort(data.shortData);
}
What is the interest of using the argument way ? Is it for a performance issue ?