Search Unity

Bug NetCode seems to be generating an empty serializer for longs?

Discussion in 'NetCode for ECS' started by HeyZoos, Jul 31, 2021.

  1. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    This code seems to cause NetCode to generate an empty serializer, despite deleting the folder and clicking "Build" through the code generation wizard.

    Code (CSharp):
    1. public struct MoveClientToServerRpcCommand : IRpcCommand
    2. {
    3.     public long X;
    4.     public long Y;
    5.     public long Z;
    6. }
    Code (CSharp):
    1. namespace Assembly_CSharp.Generated
    2. {
    3.     [BurstCompile]
    4.     public struct MoveClientToServerRpcCommandSerializer : IComponentData, IRpcCommandSerializer<MoveClientToServerRpcCommand>
    5.     {
    6.         public void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in MoveClientToServerRpcCommand data)
    7.         {
    8.         }
    9.  
    10.         public void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state,  ref MoveClientToServerRpcCommand data)
    11.         {
    12.         }
    upload_2021-7-31_13-48-33.png

    Receiving system

    Code (CSharp):
    1. [UpdateInGroup(typeof(ServerSimulationSystemGroup))]
    2. public class MoveRpcCommandServerSystem : ComponentSystem
    3. {
    4.     protected override void OnUpdate()
    5.     {
    6.         Entities
    7.             .ForEach((Entity entity, ref MoveClientToServerRpcCommand cmd, ref ReceiveRpcCommandRequestComponent req) =>
    8.             {
    9.                 PostUpdateCommands.DestroyEntity(entity);
    10.                 var group = World.GetExistingSystem<GhostPredictionSystemGroup>();
    11.                 var broadcast = PostUpdateCommands.CreateEntity();
    12.                 Debug.Log($"[SERVER] Received {cmd.X}, {cmd.Y}, {cmd.Z}");
    13.                 Debug.Log($"[SERVER] Received {new fp3( fp.FromRaw(cmd.X), fp.FromRaw(cmd.Y), fp.FromRaw(cmd.Z) )}");
    14.                 PostUpdateCommands.AddComponent(broadcast, new MoveServerToClientRpcCommand
    15.                 {
    16.                     Tick = group.PredictingTick,
    17.                     X = cmd.X,
    18.                     Y = cmd.Y,
    19.                     Z = cmd.Z
    20.                 });
    21.                 PostUpdateCommands.AddComponent(broadcast, new SendRpcCommandRequestComponent());
    22.             });
    23.     }
    24. }
     
  2. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    Ah there's no bug, they just have to be transmitted as ulongs