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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Feedback Be Careful with Pre-processor defined NetworkVariables

Discussion in 'Multiplayer' started by KingKRoecks, May 28, 2022.

  1. KingKRoecks


    Jul 28, 2013

    In this example code from the BossRoom sample, they have a NetworkVariable that is only there for the Editor, or if the DEVELOPMENT_BUILD flag is set (by checking that box on Build menu, presumably).

    The pitfall associated with this, is if you ever have an Editor connecting with a built player without the "DEVELOPMENT_BUILD" flag, your serialization will fail because this entity existing on one and not the other creates an offset in the FastBufferReader / FastBufferWriter by the amount of bytes that it takes to serialize this.

    And that... from my last few weeks experience... is a hard F***ing bug to track down.
    Cranom and thethanksforthegod like this.
  2. thethanksforthegod


    Feb 18, 2020
    thanks bro It's really so hard to figure that and that offset will break everything it's a fatal bug.
    KingKRoecks likes this.