Difference between gameObject and GameObject and a scene item named "GameObject" and this in context of Unity grammar

This is related to another thread, except `this` was not compared there, nor Unity's usage of capitalization and inclusion of spaces-in-variable-names-in-editor,* so for clarity, please explain here!

(Community wiki)

Some further questions:

  • Why are variables called cameraOffset labeled as "Camera Offset" in inspector? Why the inclusion of a space?

  • Why is it that when you have a Mesh.js in asset, it'd stop the whole show? Is there a list of "forbidden file names"?

  • Why are variables called cameraOffset labeled as "Camera Offset" in inspector? Why the inclusion of a space?

This is because the GUI has a function to make variable names readable - it'll turn camelCaseName into Readable Language Name. It splits every time it finds a capital letter in the camel case version, adding a space there.

  • Why is it that when you have a Mesh.js in asset, it'd stop the whole show? Is there a list of "forbidden file names"?

Any time you overload the name of a unity class, it'll go wonky. Check the list of classes used in the runtime api here: http://unity3d.com/support/documentation/ScriptReference/20_class_hierarchy.html

The difference between 'GameObject' and 'gameObject' is as described in the other thread (although I'm not sure about the GetComponent() part - I've never seen that before, and I haven't tried it myself).

For a game object to be named 'GameObject' is completely incidental and has nothing to do with the class named 'GameObject'. It would be like if you had a cat and named it 'cat'. Yes, the cat's name also happens to describe what it is, but that's incidental; the cat could just as well be named 'Mittens' or 'Fluffy'.

Regarding cameraOffset vs. Camera Offset, that's just a (sort of confusing) bit of 'humanization' that Unity does for you. The variable is, indeed, named cameraOffset, but Unity 'humanizes' variable names for display in the inspector. This means that the names of the variables as seen in the inspector are often different than the variables' actual names in the source code. (Among other things, a space is not a valid character for symbols such as variable and function names, etc.)

Not sure about Mesh.js, but I'd guess it has something to do with the fact that there's already a class called Mesh (maybe). [Edit: See Mike's answer above.]