Components

Components are the “guts” of a GameObject. They are the details of our house such as the walls, the front door, or the windows. Without them, we merely have a slab of concrete. Adding these elements will give it life. For a GameObject, adding a Component will help define its properties such as appearance or behavior.

Just about every asset (with the exception of a Prefab) can be used as a Component in your game. Sprites, scripts, animations, and effects all need a GameObject to exist in the Scene. We attach all of these elements as Components.

If we look back at Figure 2.4, we see that our Main Camera has five Components that are often used to create our game elements: Transform, Camera, GUI Layer, Flare Layer, and Audio Listener. ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation 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.