Search Unity

TMP Dynamic text dictionary definition

Discussion in 'UGUI & TextMesh Pro' started by Gekigengar, Nov 21, 2020.

  1. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Hello, I have a bunch of key words with a description of its meaning in JSON format that I want to display when a user mouse over the text on the NPC dialog in an attempt to reduce the need of exposition.

    Such as for example
    Code (CSharp):
    1. "Nargacuga":
    2. {
    3.     "Description": "A flying wyvern covered in pitch black fur.
    4. It is extremely agile, especially on the ground, moving with explosive bursts of speed."
    5. }
    How do I create such system so that I do not have to manually place links on each text when I add/remove definitions?
    How would you do it?

    Thank you!
     
  2. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    I just found out about <link=""></link> in TextMeshPro. I probably can create a component that automatically parse over text and dynamically create link when text is initialized/changed, then create a tooltip UI that reads and display the link description.

    I now need a OnTMPMouseOverLink(LinktInfo info) event handler. (Does this even exist? If not, why not?)

    From surfing through solutions, the answer always points out to a "TextMeshPro Examples" asset, but I cannot find anything regarding that package.

    How to operate and work with TMP programatically is always mysterious to me..
    Where are the documented samples?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Take a look at example 12 and 12a included in the TMP Examples & Extras.

    Example 12a has an event handler which you should be able to use / adapt for your needs.
     
  4. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Yeah, after trying to find the example package, apparently its within the "Packages/TMP" folder instead of it being in the package manager like all other Unity packages. I have a hard time finding it, and I finally found it. Thanks!
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    upload_2020-11-21_23-55-2.png
     
    Gekigengar likes this.