Search Unity

C# variable names do not match Unity UI names

Discussion in 'Scripting' started by awilki01, Jan 25, 2015.

  1. awilki01

    awilki01

    Joined:
    Jan 25, 2015
    Posts:
    14
    I'm new to Unity (less than a week), but I was curious if there was a way to get variable names in the scripts to match what is shown on the Unity UI.

    For example, I have a variable declared as:

    Code (CSharp):
    1. public GameObject playerExplosion;
    In the Unity UI in the Inspector for the parent object, it has "Player Explosion" listed. I would much rather it show "playerExplosion". I know its a nit and is not all that important. Something about it just bothers me though....
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Zaladur likes this.
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not possible to prevent the inspector from "prettifying" the variable names.

    --Eric
     
    HunGARE and Ian094 like this.
  4. SevenHams

    SevenHams

    Joined:
    Dec 27, 2012
    Posts:
    67
    Don't worry about it too much, it functions properly. If you're really worried about putting stuff in the wrong place plan on that and give stuff good and distinct names.
     
  5. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Could write inspectors for everything, tho more effort than it's worth
     
    Dantus likes this.
  6. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Really I don't get what the big deal is, people tend to use to separate words in variables, and unity is just spilting it for you. If you don't want words splilt up in the inspector just don't use camelCase.
     
  7. awilki01

    awilki01

    Joined:
    Jan 25, 2015
    Posts:
    14
    Thanks everyone! This will ensure I follow good variable naming standards. It wasn't a big deal. It was just a nit.