#How can I refresh TMP_Text in Unity 6 if I change TMP_FontAsset's Fallback list?

1 messages · Page 1 of 1 (latest)

granite cargo
#

We used the following lines in Unity 2022, and it worked perfectly to modify text fonts during runtime. Unfortunately we needed to update to Unity 6 and this code doesn't work anymore. I know its not a great way to place fonts into the fallback list and refresh fonts based on that, but there's no way to rewrite this. Its an already released game made mainly in Unity 2022.
Its also not possible to reassign font types on all of the TextMeshProUGUI components, because there are hundreds of different texts all over the project in many different prefabs and gameobjects.

Is there a way to solve this without rewriting an already published game?

mainFontAsset.fallbackFontAssetTable[0] = fontAsset;

TMP_Text[] allTexts = FindObjectsOfType<TMP_Text>();

foreach (TMP_Text text in allTexts)
{
text.ForceMeshUpdate(true);
}

granite cargo
#

@wooden lava do you have an idea?

rich falcon
#

@granite cargo Please don't ping people not in conversation with you. And you can write an editor script to auto assign to appropriate component including to prefabs.

granite cargo
#

since its hard to decide from code side which component should be changed and which shouldn't

#

because they weren't got separated

#

and I can't manually add to all of them some separating components or anything

#

because this font update should not run on all of them

granite cargo
#

@rich falcon any other idea, which might be usable?