- Home /
 
               Question by 
               VesuvianPrime · May 03, 2014 at 01:57 PM · 
                inspectorstringnamefield  
              
 
              Does Unity have a "Nice Name" method?
Hi guys
If I write a script that looks like:
 public class Test : MonoBehaviour
 {
     public int someTestValue = 0;
 
     [SerializeField] private int m_SomeOtherTestValue = 1;
 }
The inspector shows those fields like:

Does anyone know how this string manipulation is done? I'm sure I could bash something together with StringBuilder and some regex, but I'm wondering if the Unity API already has a method that takes a string and outputs a nice name.
Thanks, Ves
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by liortal · May 03, 2014 at 04:35 PM
The logic is contained in the ObjectNames class (documentation: https://docs.unity3d.com/Documentation/ScriptReference/ObjectNames.html)
Specifically, check out the NicefyVariableName method:
 // Outputs the text: Some Variable Name
 Debug.Log (ObjectNames.NicifyVariableName("someVariableName"));
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                