Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[NetCode 3.0] ISharedComponentData syncing?

Discussion in 'NetCode for ECS' started by florianhanke, Sep 8, 2020.

  1. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    When I add the GhostComponent and GhostField attributes to a ISharedComponentData, the field is shown in the Ghost Authoring Component's Update component list, but a Serializer is not generated and it is not added to the GhostComponentSerializerRegistrationSystem, and it is also not synced to clients.

    Here's the component:

    Code (CSharp):
    1. [GhostComponent(PrefabType = GhostPrefabType.All)]
    2. public struct Soldier : ISharedComponentData
    3. {
    4.     [GhostField] public short squadId;
    5. }
    Is this the intended behaviour? Do I need to use another attribute?
     
    Lukas_Kastern likes this.
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We do not support serializing shared components. Shared components are managed objects, and the serialization code is burst compiled - which means we cannot use managed objects in it. It showing up in the inspector is not intentional, it's a bug. It would also be good to have more clear messages about it not being supported - but I would have to check how feasible that is.
     
  3. cdm456852

    cdm456852

    Joined:
    Nov 21, 2017
    Posts:
    33
    So I reported some bugs about the netcode code package 0.3 version. When you guys release the next version to
    fix these bugs?
     
  4. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks, Tim! I didn't know that they can reference unmanaged types – TIL, cheers :)