Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

SerializeField

Discussion in 'Documentation' started by Qaraxanli, Jun 6, 2018.

  1. Qaraxanli

    Qaraxanli

    Joined:
    May 17, 2016
    Posts:
    2
    Hello,

    Quoting from beginning of the documentation on SerializeField: "You will almost never need this". From my (limited) experience, I can say that it is the standard way to make fields/variables editable and definable through Unity Editor, without making them public. Please enlighten me. :)

    Yet another section (starting statement) in that page states that SerializeField is used to "force Unity to serialize a private field", but I guess the purpose here is just to simplify things, as slightly down the page it says "... nonpublic nonstatic fields marked with the [SerializeField] attribute".

    Cheers, Sahin
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,175
    There's some bad advice in the docs. This is an instance of this. It makes perfect sense to use SerializeField a bunch, unless you really want all of your serialized fields to be public.
     
  3. Qaraxanli

    Qaraxanli

    Joined:
    May 17, 2016
    Posts:
    2
    Ow, I see. I thought perhaps there is a better way out there. It's just like StackOverflow, I guess, but without comments to warn you...