Access Modifiers in C# for Unity Game Development

João Henrique Machado Silva
The Polyglot Programmer
4 min readMar 30, 2023

--

What are they and how to use it?

Introduction:

In the world of Unity game development, C# is a widely-used programming language that offers robust features and functionalities. Among these features are access modifiers, which control the visibility and accessibility of class members.

In this blog post, we’ll explore the different access modifiers available in C# and how they can be utilized in Unity game development. We’ll also provide use cases and code examples to help you understand how to effectively apply access modifiers in your projects.

Understanding Access Modifiers in C#:

Access modifiers are keywords that determine the visibility and accessibility of class members, such as fields, properties, and methods. There are five access modifiers in C#:

  • Public: Accessible from any class or assembly.
  • Private: Accessible only within the containing class.
  • Protected: Accessible within the containing class and any derived class.
  • Internal: Accessible within the same assembly.
  • Protected Internal: Accessible within the containing class, derived classes, and the same assembly.

--

--