Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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:
    4
    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. AnneSchmidt

    AnneSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    1,137
  3. VishwasGagrani

    VishwasGagrani

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

    AnneSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    1,137
    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:
    8,628
    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. AnneSchmidt

    AnneSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    1,137
    Properties require capitalisation in fact:

     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    8,628
    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. AnneSchmidt

    AnneSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    1,137
    These properties you are talking about and the one explained in the video are not the same thing.
     
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    23,827
    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.