Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

Question Any way to detects inline Sprites to get sprite name/index While hovering on an inline sprite?

Discussion in 'UGUI & TextMesh Pro' started by daniel8881, Jan 10, 2023.

  1. daniel8881


    Oct 22, 2021
    I know there's a way to detect text by using TextUtilities something like the following snippets:

    Code (CSharp):
    1. string hoveredWord;
    2. int wordIndex = TMP_TextUtilities.FindIntersectingWord(description, Input.mousePosition, null);
    4.         if (wordIndex != -1)
    5.         {
    6.             hoveredWord = description.textInfo.wordInfo[wordIndex].GetWord();
    7.             Debug.Log("hover on " + hoveredWord);
    8.         }
    However, it can only print out words, it prints out Nothing on inline sprites 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 do a similar effect like the video has shown :

    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 especially sprite name or sprite index while hovering on an inline sprite? Thank you!