0

In my MRTK Testing App I spawn multiple GameObjects(Interactables) with information from a small API. I now want to show the GameObject names in a tooltip when they get focused by anything. After a bit of googling I learned that there is a class named ToolTipSpawner but for me it is not clear what I have to do in Order to actually spawn and attach a tooltip.

What do I need to do to spawn/instantiate a tooltip from the tooltip spawner? Are there other, more practical ways?

lellek
  • 162
  • 1
  • 1
  • 10

2 Answers2

0

Just add the ToolTipSpawner component to your GameObjects. The tooltip you want to show can be set with the Prefab property in the component script inspector. Please take a look at the TooltipExamples scene under the Assets/MRTK/Examples/Demos/UX/Tooltips/Scenes folder to know how to use the component.

Hernando - MSFT
  • 2,895
  • 1
  • 5
  • 11
  • I can assign a prefab, but I cannot seem to edit the text or the position of the spawned tooltip. How can I get the tooltip object that was just generated from the ToolTipSpawner? – lellek Mar 24 '22 at 17:15
  • We can't edit the text of the tooltip object that was just generated from the ToolTipSpawner because the ToolTipText will be reassigned each time the tooltip object is activated. And, the ToolTipText is a `private` field of the ToolTipSpawner class. However, no one can stop you from modifying the existing SDK source code in your machine. – Hernando - MSFT Mar 25 '22 at 08:36
0

Open the original script of hololens called ToolTipSpawner.cs and change the toolTipText to public like this

    [SerializeField]
    public string toolTipText = "New Tooltip";

In your other code you can change the text of tooltip with some like this code

toolTipSpawner = this.GetComponent<ToolTipSpawner>();
toolTipSpawner.toolTipText = "Amaze description of object";