Just like information in real life, some data needs to be protected or shared with specific people. If there's no need for a variable to be changed in the Inspector window or accessed from other scripts, it's a good candidate for a private access modifier.
Perform the following steps to update LearningCurve:
- Change the access modifier in front of currentAge from public to private and save the file.
- Go back into Unity, select the Main Camera, and take a look at what changed in the LearningCurve section.
Since currentAge is now private, it's no longer visible in the Inspector window and can only be accessed within the LearningCurve script. If we click Play, the script will still work exactly as it did before:
This is a good start on our journey into variables, but we still need to know more about what kinds of data they can store. This is where data types...