Understanding components
Components in Unity are the building blocks of any game; almost everything you will use or apply will end up as a component on a GameObject
inspector in a scene.
Until you build your project, Unity doesn't know which components will be in the final game when your code actually runs (there is some magic applied in the editor). So, these components are not actually attached to your GameObject
inspector but rather linked to them.
Accessing components using a shortcut
Now, in the previous Unity example, we added some behind-the-scenes trickery to enable you to reference a component without first discovering it. We did this by adding shortcuts to the MonoBehavior
class that the game object inherits from. You can access the components with the help of the following code:
this.renderer.collider.attachedRigidbody.angularDrag = 0.2f;
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www...