class, function and variable capitalisation

I’m having trouble understanding the capitalisation in the api, perhaps it’s my Java background. For example, I would expect Transform to be a class and transform to be a function within a class but when I see stuff like transform.Rotate I am getting really confused?

transform.Find(“spawnpoint”).transform.position - this I kind of get, position is a variable and transform is an attribute of the current object but how did Find get there, is it a class which is just created on the fly?

Anyone got any ideas or docos on name conventions within Unity??


The big idea would be Transform is the component in general while transform is the Transform attached to an object.

transform holds the member functions and variables of the object.
So transform.Find(“spawnpoint”).transform.position means you are into the transform of the object and it has a member function Find that will look for a child of the object and again look for the transform.position of the child object.

BUT if you want an array of Transform object

var array :Transform;

because you want the type of Transform and those one will have transform.position, transform.rotation and transform.scale which are the 3 main members of the transform.

So Transform= generic term

transform=the actual component in the object.

Any clearer?

In Unity functions usually start with a capital letter and variables are lowercase.
Check out the script reference to get a better feeling for the naming convention:

Classes and functions are capitalized, variables are lowercase. Look in the docs for the Component class…you can see that transform is a variable of that class. It’s probably something like

class Component {
    public Transform transform {
        get {return GetComponent(typeof(Transform)) as Transform;}