Search Unity

TextMesh Pro In a script, is there a way to check if a sprite tag is rendered?

Discussion in 'UGUI & TextMesh Pro' started by AcademyOfFetishes, Mar 10, 2019.

  1. AcademyOfFetishes

    AcademyOfFetishes

    Joined:
    Nov 16, 2018
    Posts:
    219
    I write automated tests for my game, and I just had a regression pop up: My <sprite> tags were working but they no longer work. They print like this:



    Because the .text of the TextMeshPro object is the same string whether or not the sprite is rendered, I can't use that to check if things are working correctly. Is there any way to know on a TextMeshProUGUI if the sprites are rendered correctly without using my eyeballs? I'd like to automate this, so I don't need to check manually.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You should be able to check the textInfo.characterCount as sprites that do not render correctly, would render the individual characters of the tag instead of the single sprite character. As such in your test, you would be able to check if textInfo.characterIndex[x] and related properties like character or elementType is a sprite.
     
    AcademyOfFetishes likes this.