- Home /
Child of Text class not showing added public variable in insepctor
I'm currently working on a custom text class, but when i add a public variable, it does not show in the inspector. for example:
public class TextTranslate : Text
{
public string lineid;
}
When i add this to a canvas game object it behaves exactly like a text box but does not have the new variable. I have also tried making the variable serialized but no change.
Answer by IgorAherne · Mar 29, 2017 at 05:05 AM
http://answers.unity3d.com/questions/814870/why-arent-public-variables-shown-in-the-inspector.html
search for the answer by oOHicksyOo
Answer by EpiFouloux · Mar 29, 2017 at 05:30 AM
You need to create an Editor Script.
[CustomEditor(typeof(TextTranslate))]
public class MyTextTranslateEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
TextTranslate i = (TextTranslate)target;
}
}
Put that script in Assets/Editor folder and it should work fine, everything will appear
Your answer
![](https://koobas.hobune.stream/wayback/20220612114106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
An OS design issue: File types associated with their appropriate programs 1 Answer
HideInInspector with inherited variables 1 Answer
Make a field in inspector hold inheriting classes 2 Answers
Hide headers and variables in inspector from parent classes 1 Answer
Parent Class variables in Child Class's Inspector (C#) 0 Answers