Search Unity

TextMesh Pro Rich Text Tags does not work when programmatically set

Discussion in 'UGUI & TextMesh Pro' started by merpheus, Nov 6, 2019.

  1. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    202
    Hey there, I have been having a little weird problem with TextMeshProUGUI now, the thing is, I have an array of serialized texts when I try to set them one by one to my textmeshprougui array, the rich text that they have will not be interpreted as rich text but displayed directly.

    If I type even one letter or something to existing texts in runtime, they got corrected. I am suspecting an execution order issue but still unsure. Example code for reproducing at the down below. Please use rich text tags in the inspector for strings.

    Code (CSharp):
    1. [SerializeField] private string[] myTexts;
    2. [SerializeField] private TextMeshProUGUI[] myTextGuis;
    3.  
    4. private void Start()
    5. {
    6.     for(var i=0;i<myTexts.Lenght;i++)
    7.     {
    8.          myTextGuis[i].text = myTexts[i];
    9.     }
    10. }
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide an example of the text you are using? Please copy / paste the text in quotes.