I have seen countless threads about text not updating but wasn’t able to find anything too useful.
I’m writing a component that manages a TextMeshProUGUI. My component has a text field which sets TextMeshProUGUI’s text property. As I type into my text field in edit mode, I can see in TextMeshProUGUI’s inspector that the text field does change, however the text itself as seen in the scene view or game view doesn’t change - until I make some other change like move the text, disabling and enabling it, or just deselecting the gameobject and reselecting it.
If I play the game, everything works fine and the text will update as soon as I set the text property.
I have tried all sorts of extra method calls like:
- TextMeshPro.SetAllDirty();
- TextMeshPro.ForceMeshUpdate();
- Canvas.ForceUpdateCanvases();
- LayoutRebuilder.MarkLayoutForRebuild(GetComponent());
Nothing works! Except if I do this:
TextMeshPro.enabled = false;
TextMeshPro.text = value;
TextMeshPro.enabled = true;
Which makes for a very slow editor when typing text
We are using version 2.1.1 in Unity 2019.4.1
Any suggestions? Thanks