I am new to Unity And C#. Usually I can get answers online when I encountered problems, but this one I couldn't find any clue. I know there's a way to detect text by using TextUtilities something like the following snippets:

string hoveredWord;
int wordIndex = TMP_TextUtilities.FindIntersectingWord(description, Input.mousePosition, null);

if (wordIndex != -1)
    hoveredWord = description.textInfo.wordInfo[wordIndex].GetWord();
    Debug.Log("hover on " + hoveredWord);

However, it can only print out words, it prints out Nothing while hovering on an inline sprite. I've also tried use TMP_SpriteAsset, but it doesn't seem there's a similar method as TextUtilities.

I'd like to make an effect similar to what you can see in this video : at 0:37, the textbox/tooltip is triggered while the mouse is hovering on the inline sprite.

My question is, is there any ways to GET any info of inline sprites in a TextMeshPro, especially the sprite name or sprite index while hovering over it? Or is there other way that I can implement the effect by using other ways?

  • \$\begingroup\$ You can render icons directly in your TextString (gamedev.stackexchange.com/questions/192004/…), you could test if the Tag is enough to find with TextUtilities \$\endgroup\$
    – Zibelas
    Jan 20, 2023 at 8:27
  • \$\begingroup\$ Wow, that's helpful. It looks a bit advanced to me. I will try it out. Thank you so much! \$\endgroup\$
    – Hippo
    Jan 20, 2023 at 23:09
  • \$\begingroup\$ If you struggle with implementing it, you can always post a question with what you did and what is not working (the error you get) \$\endgroup\$
    – Zibelas
    Jan 21, 2023 at 20:33


You must log in to answer this question.

Browse other questions tagged .