O'Reilly logo

HoloLens Beginner’s Guide by Jason Odom

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Access modifiers

In Unity, when declaring class-scope variables, we need to declare an access modifier. The options available are private, public, or protected. If no access modifier is chosen, private is assumed. One of the main reasons to make variables in Unity public is to be able to access them in the Unity Inspector.

In C#, this means:

  • Private: This means the access modifier cannot be accessed by other scripts
  • Public: This means the access modifier can be accessed by other scripts
  • Protected: This means the access modifier can only be accessed by internal or derived sources

In Unity, this additionally means:

  • Public: A variable shows up in the editor and can be changed outside of the script
  • Private: Variables do not show up in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required