Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Networking Missing NetworkReader.ReadFloat?

Discussion in '5.1 Beta' started by Shinyclef, Jun 6, 2015.

  1. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    NetworkWriter has a Write(double value) and Write(float value), but NetworkReader only has ReadDouble() and not a ReadFloat(). Is this intentional or just missing?

    Also are there any examples or guides on using OnSeralize and OnDeserialize? I'm ok to wait for release build documentation though. I'm kind of finding my way though this slowly slowly :).

    Thanks :)
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    .ReadSingle()
     
  3. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Many thanks :)

    As some feedback if any Unity guys are looking. It might be worth considering matching the terminology on both sides? The description of ReadSingle() is
    so why not just make it ReadFloat()?

    Not too fussed myself now that I know, but I bet others will also use WriteFloat() and look for ReadFloat().
     
  4. Indiefreaks

    Indiefreaks

    Joined:
    Nov 12, 2012
    Posts:
    89
    This is by convention on the .Net framework.

    As you probably know, .Net and thus Mono are meant to support many languages even if C# is the common one.
    On many languages, "float" doesn't exist per say. It's a C like terminology that is used in some languages such as C#.

    As so, when Microsoft worked on the framework, they decided to find some terminology that would work on all cases, thus the types Single and Double that represent respectively Single and Double precision floating numbers.

    The Unity team simply used the conventions as they actually are reading Single type values. Doing so, they keep to the convention and assure to support other .Net languages in the future. ;)

    Hope it clears things a bit. :)
     
    AlwaysBeCoding247 likes this.
  5. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    It does, thanks.
    Makes sense now :)