Search Unity

Why do we use [serialized field] ? i can skip it!

Discussion in 'Multiplayer' started by LiOn0X0HeaRt, Jun 26, 2015.

  1. LiOn0X0HeaRt

    LiOn0X0HeaRt

    Joined:
    Jul 14, 2014
    Posts:
    38
    Hi
    i tried to send the position with serialized field and without it
    the code works fine on both
    i think its smoother with serialized field but i am not sure

    i don't want to post my code cause i just want to know why do we use it when we are networking?
     
  2. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    I assume you're talking about the [Serialise Field] attribute.It's not specific to networking. It exposes the variable to the editor so you can assign values in the editor in the same way as public fields. As public fields are automatically exposed to the editor, you don't need it for public fields. However, sometimes you don't want to make an variable public just to expose it to the editor, you might like to keep it private. This is the case when it's most useful.

    There may be other usages that I'm not aware of.
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562