$ ./guess_the_languageGame Dev
Game Dev · medium · #107

Why use [SerializeField] on a private field?

[SerializeField] private int lives = 3;
  1. Expose it in the Inspector safely
  2. Make it public to all scripts
  3. Run it before the scene loads
  4. Compile it out of the build
It lets the editor edit a private field without widening its code access.
Play Game Dev ▸