Properties are smart variables where you can gain information out of them and run functionality through them. They allow you to get information and set information.

You want to be able to get and set your properties. To do this follow the example where we want to know if our game is over. So we set a private bool isGameOver. Then we set a public bool IsGameOver where we get and set our return and value.

Now we will be cleaning this up by looking at auto properties. If you wanted people to only be able to read game over, but not be able to set it, you could delete the set value. To control this you need to create a private set. It could also be a protected set for those that inherit it could make changes, but nowhere else.

The downside to auto-properties is not being able to use any function code within it.

To be able to view properties in Unity, you will either need to use a custom editor or go to debug mode in Unity, but that is the only way to see it.

Next, I will be working on a challenge where I will be creating two properties. One for speed that is read only and one that is public. They are to have debug logs to show when they are getting called.

With speed you cannot set the value as you can only obtain it, but with the name you can set it as well.

It is typical to use properties when working on manager classes. Ex: GameManager, PlayerManager, etc…

Unity Developer