Unity has all of it's class methods in capital. Any particular reason to adopt a different practice?

Whenever I see unity code, it makes me doubt if I am missing something. I see the class methods in capital letters. Is their any specific reason why this way is adopted which is different from the common practice. For example, generally class names are capitalised and other things are small letters. Or probably unity has some different rules for functions, I might be missing?

I’m not sure what you mean by “I see the class methods in capital letters”: Unity - Scripting API: MonoBehaviour

For example if you see “CompareTag” instead of “compareTag” . Why the first letter is capital, when it’s a function/method ?
I understand it’s not a big deal, and may be it’s just how Unity has set the standard. But just wanted to be sure, if there is something which I may not be knowing like the reason behind the change in this trend in Unity scripting.

Because lower case letters are used for other things, mainly variables, and probably other reasons I’m not aware about. :slight_smile:

PascalCase is the standard naming convention for methods in C#. (See Microsoft’s Capitalization Conventions.) In this regard, Unity follows the standard convention.

One of the main areas where Unity differs from the standard convention is property names. These are usually PascalCase, too, but Unity uses camelCase.

So long as you’re consistent with yourself, just choose one standard and stick with it.

2 Likes

Properties require capitalisation in fact:

https://www.youtube.com/watch?v=BYwCXJ-J9dA

This is a case of “Do as I say, not as I do.” :slight_smile:

In Unity’s APIs, properties such as MonoBehaviour.name and MonoBehaviour.transform are lowercase.

2 Likes

These properties you are talking about and the one explained in the video are not the same thing.

Subject common in general discussion, so it’s locked (it’s also off topic for this section of the forum, which deals with actually scripting, not criticising the house style used by a company).

There are many similar topics that can be added to if you want.

2 Likes