2
votes

im trying to solve a very special issue, may one of you have a similar problem, I'll extend the class TextMeshProUGUI from Unity's package manager just for add a simple string extra property for localization called m_key for those who will use this GameObject only have to put the key for the localized string on the editor and check how it looks like the TMPro text with the localized string, ok, i'll copy all the custom TextMeshPro editor in a new editor class just for show the localized text in the unity editor with the next code on the OnInspectorGUI function:

m_key = EditorGUILayout.TextField(new GUIContent("LOCALIZED KEY:"), localized_key.stringValue, GUILayout.Height(18), GUILayout.ExpandWidth(true));
localized_key.stringValue = m_key;
text_prop.stringValue = LanguageWizard.GetGameText(localized_key.stringValue);

Where m_key its just a string variable in the editor class and localized_key comes from the property m_key on the extended class and at this point actually works well, but the issue is when in the Unity Editor try to deactivate the game object or its parent, the parent hides, the TMPro hides but the text property is still visible in the editor while the normal editor behaviour its hiding, may be i mess a little with custom editor of the TMPro, but if some one has experienced some of this please help.

1
The OnInspectorGUI has actually nothing to do with Gizmos ...derHugo
Yes, edited broChrisID58
Extending unity components like this (namely, adding a custom inspector) does weird things. When I did it 2-3 years ago, it'd dump am error that didn't impact usability on the console and I just had to ignore it.Draco18s no longer trusts SE

1 Answers

1
votes

After a research in the code, my team and i come to the next scenario, where i put the OnEnable and OnDisable methods for some subscription code and stuff, and we notice that this class its extended from the TextMeshProUGUI class these methods where inherited from base methods and i forgot to call base.OnDisable and base.OnEnable, when i write them and test the results int the editor, the text hide normally

protected override void OnEnable()
{
    base.OnEnable();
    //Custom Stuff
}

protected override void OnDisable()
{
    base.OnDisable();
    // Custom Stuff
}

This works on the version of TextMeshPro 1.24, the next version 1.3 will cause some issues on the custom inspector class