Putting the building blocks together
With the building blocks squared away, it’s time to do a little Unity-specific housekeeping before wrapping up this chapter. Specifically, we need to know more about how Unity handles C# scripts attached to GameObjects.
For this example, we’ll keep using our LearningCurve
script and Main Camera GameObject.
Scripts become components
All GameObject components are scripts, whether they’re written by you or the good people at Unity. The only difference is that Unity-specific components such as Transform
and their respective scripts just aren’t supposed to be edited by users.
The moment a script that you have created is dropped onto a GameObject, it becomes another component of that object, which is why it appears in the Inspector panel. To Unity, it walks, talks, and acts like any other component, complete with public variables underneath the component that can be changed at any time. Even though we aren...