Displaying public variables in the Inspector panel
I'm sure you're wondering what the word public
means at the beginning of a variable statement:
public int number1 = 2;
It means that the variable will be visible and accessible. It will be visible as a property in the Inspector panel so that you can manipulate the value stored in the variable. It also means it can be accessed from other scripts using the Dot Syntax. You'll learn more about the Dot Syntax in Chapter 6, Using Dot Syntax for Object Communication.
Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.