Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question writer.WriteValueSafe(ConnectionData);

Discussion in 'Netcode for GameObjects' started by erdmannjacob0, Mar 17, 2023.

  1. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    Anyway to override the max amount of this connection data? I am sending a lot of data in with the player such as inventory, equipment and class features but this seems to have a limit of 1024 bytes. I couldn't find a way to send this data fragmented, anyone have any ideas?
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    677
    Can you share some of the code, like where the writer is coming from and the ConnectionData stucture. I'm using WriteValueSafe a lot but only for more primitive values, more complex types have their own serialisation methods with their own WriteValueSafe calls.
     
  3. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    Well the issue comes from :
    public void Serialize(FastBufferWriter writer)
    {
    if (ShouldSendConnectionData)
    {
    writer.WriteValueSafe(ConfigHash);
    writer.WriteValueSafe(ConnectionData);
    }
    else
    {
    writer.WriteValueSafe(ConfigHash);
    }
    }
    but this is the standard connection serializer in the netcode for gameobjects package. Sounds like I am gonna have to overwrite this, hopefully that 1024 byte size is a variable I can change.
     
  4. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    677
    Check writer.maxCapacity, I'm getting 64k and can write that much data minus a little overhead.
    How are you sending the data in with the player?
     
  5. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    public const int NON_FRAGMENTED_MESSAGE_MAX_SIZE = 1300;

    looks like this could be my issue, I will run some tests editing this then come back and post my findings.
     
  6. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    Looks like that wasn't the issue, not sure where else this could be set at.