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

Question Custom IElementDataBuffer Serialization

Discussion in 'NetCode for ECS' started by Opeth001, Sep 18, 2023.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,068
    Hello Unity Team,

    The default serialization logic currently resend the entire buffer when the element count changes, as it's challenging to determine precisely what has changed. However, in our scenario, we utilize a custom IElementDataHashMapBuffer where everything is stored as key-value pairs.

    What are the available approaches for developing a customized serialization logic for our specific IElementDataBuffer?

    Thanks !
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    Not many that are easy to do.
    Buffer serialisation logic is largely opinionated at the moment, and somewhat all code-generated, and this is where we are actually encoding how the buffer need to be serialized/deserialized.
    Because in general we couldn't know the content of the buffer and if the size is changed, we don't do any delta compression.
    To change that logic it is required to make changes in the template and some places in the package too (ghost receive system in paricular).
    While plenty doable, it is not definitively the easiest thing to change.

    We are planning to add more options for that and to let specify that behaviour a little bit more (i.e: element are still delta compressed) but in order to customise many of the serialisation aspect we need to refactor the seriallzatoin support to let user customise the behaviour as they want.
     
    Opeth001 likes this.
  3. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,068
    I prefer to stick to no custom serialization until an official way to do this is released.
    Thanks !