Search Unity

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

Discussion in 'Scripting' started by VishwasGagrani, Dec 8, 2018.

Thread Status:
Not open for further replies.
  1. VishwasGagrani

    VishwasGagrani

    Joined:
    May 12, 2018
    Posts:
    84
    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?
     
  2. Deleted User

    Deleted User

    Guest

  3. VishwasGagrani

    VishwasGagrani

    Joined:
    May 12, 2018
    Posts:
    84
    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.
     
  4. Deleted User

    Deleted User

    Guest

    Because lower case letters are used for other things, mainly variables, and probably other reasons I'm not aware about. :)
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    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.
     
    Ryiah and hippocoder like this.
  6. Deleted User

    Deleted User

    Guest

    Properties require capitalisation in fact:

     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    This is a case of "Do as I say, not as I do." :)

    In Unity's APIs, properties such as MonoBehaviour.name and MonoBehaviour.transform are lowercase.
     
    Ryiah and hippocoder like this.
  8. Deleted User

    Deleted User

    Guest

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

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    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.
     
    Ryiah and ThermalFusion like this.
Thread Status:
Not open for further replies.