Code Sample 2.6

The following points summarize the code sample:

  • In Unity, class variables declared as public (such as public float MaxTime) are displayed as editable fields in the Object Inspector of the editor. However, this applies to a range of supported data types only, but it's a highly useful feature. It means that developers can monitor and set public variables for classes directly from the Inspector as opposed to changing and recompiling code every time a change is needed. The private variables, in contrast, are hidden from the Inspector by default. However, you can force them to be visible, if needed, using the SerializeField attribute. The private variables prefixed with this attribute, such as the CountDown variable, will be displayed ...

Get Complete Unity 2018 Game Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.