Search Unity

Why should unity properties begin with lowercase?

Discussion in 'Scripting' started by henriquelsm, Mar 20, 2019.

  1. henriquelsm

    henriquelsm

    Joined:
    Jan 3, 2018
    Posts:
    5
    I made the update for Rider 2018, since then I get warnings similar to this one.

    Name 'OnUnLoadSceneEvent' does not match rule 'Unity serialized field'. Suggested name is 'onUnLoadSceneEvent'.

    The warning is displayed only on properties injected by Unity.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    4,626
    It is optional convention, as many other conventions.
    Weather naming as Camel Case, or Upper case, or other.
    Generally is good to pick one standard and stick to it, across whole project.

    Just take Unity naming with grain of salt, as sine may seams all over the place.
    Consequence of decade Unity development. ;)
     
  3. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    799
    If you use Resharper C#, it suggests/recommends _lowerCamelCase naming convention for private fields and UpperCamelCase one for public fields and properties.
    You should Adhere to it. Also, you can change these rules in Resharper setting section or even disable this warning.
    You can check all naming conventions in Resharper->Options->Code Editing->C#->Naming Style
     
    Last edited: Mar 20, 2019
  4. BiomotionLab

    BiomotionLab

    Joined:
    Oct 9, 2018
    Posts:
    2
    This doesn't seem to get rid of that warning. There's no option for public serialized unity fields
     
  5. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    799
    I do not understand why you want to change rules for serialized public fields!
    Yes, I think that you can not add a new rule for specific "serialized public fields"
    You can definitely remove warnings using (Alt+Enter) and select or change it.
     
  6. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    584
    I'm reading this as: The new Unity code editor is great. No longer crashing when you type too quickly, and the code-completion finally works all of the time. You no longer have to navigate away and back to enable folding. And when you get frustrated, the warnings will give you a chuckle.

    Does it do that super-annoying thing VS-code does, where you type 1/2 a variable, pause, and it pounces to underline it in red, along with big parts of the code below? Or, gah - does it show named parameters as completion options? Like if you're calling Min(int n1, int n2), it gives you "n1:" as an option? Just the worst.