Page 1 of 1

Tooltips in TextMeshPro Text

Posted: Fri Jun 21, 2019 2:15 pm
by Maltakreuz
I would like to implement some mouse-hover tooltips for my quests. So if mouse placed over item or npc-name inside dialogue, a tooltip with appropriate info will be shown. I googled how to implement tooltips in Unity UI, it looks easy. But straightforward way to do this is just make every word with tooltip a single ui-button with mouse-enter/mouse-exit triggers.

Unfortunately this means that i can not just use one text-mesh-pro for Subtiitle Text panel that just keeps alle subtitle text. So i need to repimplement subtitle fillment to break Subtitle text on words with tooltips, make them separate TextObjects and attach the following text. Straightforward but a little bit hard to implement way. Moreover it could have some side effects with Dialogue System, since having just Text or Text-Mesh-Pro UI-object for subtitles is common way.

So may be there is some another way to implement it, with only using one text-mesh-pro object. Ideally like this:

Code: Select all

Hello adventurer, did you found a <tooltip="id_343">broken sword</tooltip> that i am looking for?
Any ideas? Or may be there is some another way for context help in dialogue system?

Re: Tooltips in TextMeshPro Text

Posted: Fri Jun 21, 2019 3:49 pm
by Tony Li
Hi,

Use the <link> tag in TextMesh Pro:



The TextMesh Pro examples package contains a Link Example scene that contains an example of how to do something when the user hovers over a <link> tag.

Here's another tutorial on using <link> tags for hyperlinks:

Hyperlinks in Unity UI Using TextMesh Pro

You can follow the same idea for tooltips instead of hyperlinks.

Also see the Unity blog post: Making the most of TextMesh Pro in Unity 2018.

Re: Tooltips in TextMeshPro Text

Posted: Fri Jun 21, 2019 5:10 pm
by Maltakreuz
Amazing stuff! Thank you very much, thats exactly what i need for tooltips.

Re: Tooltips in TextMeshPro Text

Posted: Fri Jun 21, 2019 5:18 pm
by Tony Li
Glad to help!