Private Serialized vs Public, The Actual Effect on a Game

Hello,

I’m speaking about code safety, here.

Before I continue, I’ve read many many many many sources describing exactly what it is to serialize a private or public variable. That is not what I’m confused about.

If you’re coming to this question and you don’t really know what I’m talking about:

These are just a few of the dozen that I read over the past couple of months…

I also know the difference between public and private variables.

What I do NOT know, is the difference between a private variable that can be accessed in the inspector versus a public variable.

By that, I mean I do not know the “safety” difference between using a serialized private or a public. Are serialized privates more prone to corruption?

public variables can have their values altered in code outside the class, private variables cannot.

Serialized private fields will still be read/written to when being serialized.

So, they are really two separate concepts. You should only make the private field serialized if you want its state saved when serializing the object onto the hard-drive/across the network, or you want its value editable within the editor.