Variable names different in degugger

In the script we have declared currentScreen (one word starting with a small “c”) of type Screen. However in the inspector this variable is shown as Current Screen (2 words with capital “C”). Is there a reason for this or is this a bug in Unity?

Hi,

It’s not a bug, it’s Unity being helpful :slight_smile:

Unity is effectively parsing your exposed variable name and trying to make it more readable for the designer.

4 Likes

Hey, does this also include for “main menu”? I also came over here for a similar question-- does Unity just know that we want it to be Main Menu and not MainMenu? I know it seems petty but I went through my code just to see I hadn’t put the space in myself.

1 Like

Unity is parsing your variable name to something more readable in the Inspector. It will do this for any word you use and try its best to make it into something that would be more useful to say a designer looking at it.

Give a few variations a try and you’ll see what’s going on, you don’t have to use the variables for anything, just experiment, e.g.

public string mainMenu;
public string MainMenu;
public string _mainMenu;
public string main_menu;

Try the above and see what you get, comment three of them out of course and do one at a time or else you’ll get an error about the name being used already.

Privacy & Terms