Tooltips in TextMeshPro Text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Maltakreuz
Posts: 40
Joined: Sat Jul 25, 2015 2:36 pm

Tooltips in TextMeshPro Text

Post 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?
User avatar
Tony Li
Posts: 20544
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tooltips in TextMeshPro Text

Post 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.
Maltakreuz
Posts: 40
Joined: Sat Jul 25, 2015 2:36 pm

Re: Tooltips in TextMeshPro Text

Post by Maltakreuz »

Amazing stuff! Thank you very much, thats exactly what i need for tooltips.
User avatar
Tony Li
Posts: 20544
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tooltips in TextMeshPro Text

Post by Tony Li »

Glad to help!
Post Reply