- Unity 4.x Game Development by Example Beginner's Guide
- Ryan Henson Creighton
- 376字
- 2025-03-31 04:02:10
A capital idea
The Transform component is listed as Transform with an uppercase T. When we refer to it in code, we use a lowercase t. In the Script Reference, it has an uppercase T again. But, if you've already made the mistake of using an uppercase T in your code, Unity threw you an error in the console window. What gives?
Unity's language is case sensitive, which means that a word with a capital letter is treated as a completely different thing than the same word with a small letter. So, transform
and Transform
are as different from each other as the words night and day.
Transform
is a class. A class is like a blueprint that you use to make other things. You might implement power-ups in your keep-up game. Your capital-P Powerup
class describes what a power-up should look like and how it should behave. You might create a new power-up using your Powerup
class, and label it powerup
with a small p. The capital-P Powerup
class contains the instructions for building something, and lowercase-p powerup
is the name you gave to the thing you've built with that blueprint.

So, in this case, capital- T Transform
is the class, or blueprint, that describes how a transform works. Small-t transform
is the name our GameObject gives to its own transform instance, which was built using the Transform
blueprint. This upper-case class/lower-case instance is a coding convention, and so is not shouting at the dinner table; let's follow the convention to keep things civil.
Here are a few more examples to help you understand:
Car
is the class (blueprint). We use it to make a new car instance, which we callcar
(small c).House
is the class (blueprint). We use it to build a new house instance, which we callhouse
(small h).
We can use these classes to create multiple copies, or instances, of a thing. The Car
class could stamp out many things, which we could call car1
, car2
, and car3
. We could also call those things sedan
, convertible
, and suv
. In Unity-land, the developers decided to call the thing that was created with the Transform
class transform
. It could just as easily have been called pinkElephant
, but transform
makes more sense.