A property is a member that provides a flexible mechanism for reading, writing, or calculating the value of a private field. This provides easy access to data and promotes security and flexibility of methods.
To use a property, you must declare a private variable and its namesake by convention with the first letter capitalized and define its get and set, representing the possibility of reading (get) and writing (set).

This allows us to maintain the integrity of the data itself since it is not directly accessible being private.
Within get and set, we can also define other elements that must be called when the data is written or read.

There are also auto-properties that don’t need the declaration of a private and associated variable, but we must always explicitly define the set and manage if we want it to be public, private, or protected.

Properties can have several uses, in Unity one of these can be the use of more important variables related to the Manager classes that we write, such as the Game Manager, the UI Manager, and many others. The properties are not serialized directly by the Unity Inspector so they can only be modified by the behavior written in the code. To see them in this tab we must use the DebugMode of the Inspector or write our own Editor script that serializes them.




project manager by day, unity developer by night

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Top 10 Tools for Junior Web Developers

Creating Modular Waypoint System in Unity

Container-Diff: Change Management for Containers

Studio 02 Project: “Blade of Whoa!” PM

You should write a linter

AWS Amplify Admin UI

Two people looking at ui screens

System design basics (Part 3) — Storage

Why would it be better if we use lambda for API calls?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Alicino

Andrea Alicino

project manager by day, unity developer by night

More from Medium

Overloading methods in C# & Unity

Reverse Geocoding: Unity lambda expression

The Escape Button is a Feature

Instantiate and Destroying game objects in Unity