- Home /
How to prevent Unity editor from renaming public variables?
When a C# Component exports public variables, such as
public int mTheTest ;
public int RealGood ;
public int my_UnderScore ;
they will be displayed in the Editor GUI as
MTheTest
Real Good
My_Under Score
This is misleading, as variables are case-sensitive in C#. Replacing underscores with a space is even worse.
Is it possible to make the editor display variables as-is?
It is not possible to display the variable named "TheTest" in the inspector as "TheTest".
You will need to create an editor extension to change this.
(Excellent comments from Veehmot and Neurological)
@Veehmot: Thanks, I had forgotten the name of this and had a hard time finding it. In the end I rolled my own function to do the same, but now I guess I can just drop that!
The only way to have this shown in the inspector as "TheTest" would be to create a custom inspector GUI like @$$anonymous$$ suggested.
@benstoneman can you please give me back the authority to accept answers to my very own questions? I am an educated user and would very much like to take care of accepting answers myself.
The answer does not appear to be accepted flberger. You have the power to accept the answer. :)
Answer by $$anonymous$$ · Jun 05, 2013 at 04:20 PM
I think isn't possible, as long you put a capital letter it will space it if there isn't another capital letter before.
But mind that it shows that way only in the inspector, it doesn't rename the variable for real. You can still personalize it with a custom editor inspector script. More info in here:
http://docs.unity3d.com/Documentation/Components/gui-ExtendingEditor.html
Thank you. It's really weird to have to hack an extension to actually see what has been written plainly into the code. I think I'll file a feature request.
Answer by Veehmot · Jun 05, 2013 at 04:18 PM
I don't think there's a way to do that. I don't think there's a reason to do it anyways. The process of converting the names is called nicify, and is achieved by calling ObjectNames.NicifyVariableName, if that's any help.
The reason is at each developer's discretion, I think. :-) In our case, Unity is being used by both experienced developers and artists with little coding background. The latter occasionally have to touch scripts, and they often either a) don't recognize variables because of their different na$$anonymous$$g (thing Ctrl+F) or b) think that Variables are case-insensitive. Both is caused by the unnecessary name mangling.
I voted your idea, I agree that may put stuff more ordered for others to see codes, like for your artists, so they aren't forced to open scripts all the time.
Answer by It3ration · Jan 02, 2014 at 12:30 AM
This needs to be configurable - why not have a custom attribute? In other words:
[InspectorName( "Last Name" )] public string m_last_name = "";
I'm an engine programmer just starting to prototype in unity. I was very surprised that this feature wasn't present.
I would recommend posting your feedback using the dedicated feedback system: http://feedback.unity3d.com/
I have added a specific request for this feature here:
Your answer
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to optimize a custom editor ? 3 Answers
Editor script - any callback when target is first instantiated? 1 Answer