
Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

I want you to create one script that will be attached to two GameObjects. The script will have two methods that will cause the GameObjects to rotate left and right. This will show you that from a single script file, two separate Component objects will be created in the memory. Each Component object is a separate instance object with no absolutely knowledge of the other.
In your Scene, create two GameObjects, Capsule
and Cube
.
Add a Directional Light to the Scene so you can easily see the GameObjects.
Here's my Scene as an example:
Create a new C# Script and name it Spinner.
Code the script as shown in the following screenshot:
Attach the Spinner
script to the Capsule and the Cube GameObjects.
Modify LeaningScript
as shown in the following screenshot:
Save the file.
In Unity, click on Play.
Here's the output to the Console:
Now press the left and right arrow keys to make the Capsule spin, and the up and down arrow keys...
Change the font size
Change margin width
Change background colour