Adding Labels

Adding Labels to GameObjects in your scene is easy with the MiniMap Component in this Module. It is very similar to adding Markers (see previous Page) but as Map lables are created with Text Mesh Pro text, you must first indlue TMP in you project using the Unity Package manager.

This feature also works with Tags, and therefore you should first decide what tags you want and what Text will be used. The Tags can be anythng you want, but you must add them to your project using the Tags Editor in the Inspector. Click on any object in your scene and you will see that it is probably Untagged.

Click on the Untagged dropdown and select Add tag. Here you can add new tags using any name that is meaningful to you. We have added item, enemy, label, and green, and "label" will be used to this example.

You can add these Tags to the GameObjects. You can Tag as many Objects as you want to show in the Map with the same Tag, or have a separate Tag for every Object. This is your choice.

Next you need to add a trigger, probably and OnStart trigger, and add the Action for adding Labels.

You will notice that the first part of this Action is the same as adding Markers. You have a Scale, number of types, and the Tag for you to enter.

Next you type in the Text you want displayed, choose the colour, and if you want the Text to include a text Outline. Then there is the culling layer and this is different than the Markers. Markers use a one sided transparent Shafder and therefor are only seen by the Map Cameras and not the Player Camera. However, Text Mesh Pro does not use this shader, and if you player looks into the sky, they will see the floating Text Labels.

The solution to this problem is to add a culling layer to your Main Camera. Select your Main Camera and in the Inspector, click on Layers and select Add layer. You will see the below panel, where you can select any empty slot and add a name of your choice. We have added TMPLabels to slot 11. You then add "11" or the slot number you chose, to the Action as shown above.

Finally, back in your Main Camera, select the Culling Mask dropdown, and make sure that your culling layer (TMPP Labels) is NOT seleted. This will allow the Camera to ignore your Label Text.

And thats it. Press play and test your map markers. You should see them in both the MiniMap and the full screen Map.

For further details on Map Lables, see the Example that is included in this Module.

Last updated