Difference between case sensitive APIs

Whats difference between a Tranform and transform
Similarly there is Gameobject and gameobject

Transform is a class, while transform is most likely a member of your MonoBehaviour subclass. Same with GameObject.

I hope I’m getting the terminologies right here. xD The capitalised examples you gave (or what I assume you attempted to give - GameObject is different to Gameobject and I assume you are talking about the former) are classes whereas the non-capitalised ones are variables.

Note that gameobject is also different to gameObject, as the latter is reserved by Unity as the variable that refers to the GameObject your script is attached to, as such:

  • GameObject - class
  • gameObject - variable reserved by Unity
  • Gameobject - user-defined variable
  • gameobject - user-defined variable

In the case of Transform/transform:

  • Transform - class
  • transform - variable reserved by Unity that refers to the transform component of the GameObject the script is attached to

EDIT: waaaaah, blizzy ninja’d me. xD

Unity convention is:

  • classes and methods in PascalCase.
  • properties and fields in camalCase.

So in general the PascalCase version is referring to the class itself. The camelCase version is referring to an instance of the class.

This is just convention. There is nothing aside from posts on the forum actually enforcing this. Different languages and communities use different conventions.

So what does this code means
what does Tranform and tranform refers to in code below

void Example() {
foreach (Transform child in transform) {
child.position += Vector3.up * 10.0F;
}

A foreach iterates over an array or collection of objects. Each pass of the loop it takes the next available entry in the collection and assigns it to the variable name specified in parenthesis.

In this case the loop is taking the next available child of the GameObject with the script, grabbing its transform property, and assigning it to a varaible called child of type Transform.

void Example() {
   foreach (Transform child in transform) {
      child.position += Vector3.up * 10.0F;
   }
}

By the way, if you use code tags the forum software will automatically create forum links to the API docs. Try clicking on “Transform” in the above code. Though it doesn’t do all of them, it does get most. :wink: