How does the variable thingToFollow become recognized as Thing To Follow in the Inspector?
Hello! Welcome back to the community!
Unity is pretty clever, it reads the variable name and knows when to put on a space and a capital letter, it follows the most common naming convention which is something called Camel Case: variable names start with a lower case letter, and each different word starts with an upper case letter, based on that it can tell how to display the name properly.
Unity also properly displays names that follow other type of conventions. Take a look at the following code:
[SerializeField] float aFloatVariable = 0f;
[SerializeField] int _AnIntVariable = 0;
[SerializeField] bool m_ABoolVariable = false;
As you can see there, I have some variables that follow other conventions, like starting with an underscore, or underscores plus the letter ‘m’, this displays perfectly in the inspector:
Really cool, Isn’t it? As to how Unity exactly does that, well, your guess is as good as mine since there are many, many ways to achieve that, but it all boils down to the string class and all the marvelous things it can do, check it out in the Microsoft Documentation.
Hope this helps you understand!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.