Text Mesh Pro

This page describes how to set up the Dialogue System with TextMesh Pro. (TextMesh Pro is required.)

TextMesh Pro 1.0+ is required.


TextMesh Pro Setup

To add support for TextMesh Pro, import the package Third Party Support/TextMesh Pro Support. This will unpack files into the folder Third Party Support/TextMesh Pro.


TextMesh Pro Example Scene

An example scene is in Third Party Support/TextMesh Pro/Example/Feature Demo with TextMesh Pro. It uses TextMesh Pro for the following UI elements:

  • Barks
  • Dialogue UI (conversations and alerts)
  • Selector
  • Quest tracker HUD

TextMeshPro versions of the following UI elements are also in this package, but the example scene doesn't use them. They use Unity UI instead. You can use them to compare visuals between TextMeshPro and Unity UI:

  • Quest log window
  • Usable tag above Dead Guard
  • Computer terminal conversation

The example scene was built with the Unity-published version of TextMesh Pro, so the references in the scene point to this version. If you're using Digital Native's paid version, the example scene will not play out of the box, but all scripts will still work correctly in your own scenes.


TextMesh Pro Bark UI

The TextMesh Pro Bark UI component uses a TextMesh Pro to display text above the NPC's head. Follow these instructions to set up barks:

  1. Add a TextMesh Pro child GameObject to the actor. Name it, for example, TextMeshPro Bark UI.
    • Configure its position and appearance to your liking.
    • Add an Always Face Camera component to it.
  2. On the actor GameObject, add a Text Mesh Pro Bark UI component (Component > Dialogue System > Third Party > TextMesh Pro > Bark UI).
    • Assign the TextMesh Pro child GameObject to the TextMesh Pro field.
  3. (Optional) On the actor GameObject, add a Text Mesh Pro Bark UI Fader component if you want barks to smoothly fade in and out, or a Text Mesh Pro Bark UI Animator if you want to use animator to show/hide the bark.

The final configuration should be similar to the screenshot below:


TextMesh Pro Dialogue, Quest, and Selector UIs

Since TextMesh Pro only provides non-interactive text meshes, interactive functionality is provided through Unity UI. See Overview of Unity UI Support for information about using Unity UI with the Dialogue System. This means, for dialogue, quest, and selector UIs, you will use Text Mesh Pro UGUI, the Unity UI version of TextMesh Pro.

Setup is exactly like Unity UI, except you should use the TextMesh Pro versions of components such as TextMeshProDialogueUI instead of UnityUIDialogueUI.

Copying from Unity UI Dialogue UI

If you already have a Unity UI Dialogue UI set up and you want to switch to Text Mesh Pro Dialogue UI, you can use the technique below to retain the dialogue UI's field assignments, such as Dialogue > Panel, Dialogue > NPC Subtitle > Panel, Dialogue > NPC Subtitle > Portrait Image, etc. This way you'll only need to replace and assign the text elements.

  1. From the three-bar menu in the upper right of the inspector, select Debug to change the Inspector to debug mode.
  2. Inspect the Unity UI Dialogue UI. Drag the TextMeshProDialogueUI script into the Unity UI Dialogue UI's Script field. This will replace the script while retaining references to the panels, etc. The only fields you'll need to assign are the Text Mesh Pro UGUI fields.
  3. From the three-bar menu in the upper right of the inspector, select Normal to change the Inspector back to normal mode.​

TextMesh Pro Typewriter Effect

This support package includes an improved typewriter effect for TextMesh Pro.


TextMesh Pro Localization

To localize a TextMesh Pro element (such as a "Continue" button), add a Localize Text Mesh Pro component to it.

The Localize Text Mesh Pro component localizes the element's Text field. You can assign a localized text table to this component or the Dialogue Manager. The Text Mesh Pro component's starting text value serves as the field name to look up in the table.

If you use a language selection menu, add an Update Localized UI Texts component to any GameObject in the scene. (Components > Dialogue System > UI > Unity UI > Effects > Update Localized UI Texts) When the user selects a language, configure the event handler to invoke this component's UpdateTexts(string) method. Pass the language code (e.g., fr for French) as the parameter to the event handler.

Note: You do not need to do this for text in your dialogue database such as conversations and quests. Dialogue databases contain their own localization.

The Update Localized UI Texts component saves the current localization language setting in PlayerPrefs. To clear this, select menu item Window > Dialogue System > Tools > Clear Saved Localization Settings.

Fonts & Text for Localization

You can use the Dialogue Editor's Export Database features to export your content to separate text files for each language. You can then run these files through TextMesh Pro to ensure that your language-specific fonts include all necessary characters.


Unity UI Text To TextMesh Pro (Deprecated)

Since Text Mesh Pro has native Unity UI components, this conversion script is no longer necessary. If you need it for some reason, such as to prototype a UI that has already been designed using Unity UI Text, edit TextToTextMeshPro.cs and uncomment the lines as indicated in the file.

The Text To Text Mesh Pro component (Component > Dialogue System > Third Party > TextMesh Pro > Text to Text Mesh Pro) watches for changes to a Unity UI Text component. When the text changes, it redirects the change to the TextMesh Pro UGUI* component. You can use it anywhere to "convert" Unity UI to TextMesh Pro.

For the Text elements that you want to replace with TextMesh Pro:

  1. Create a TextMesh Pro UGUI version.
  2. If you are using auto layout, tick Ignore Layout on the Text element.
  3. Add a Text To Text Mesh Pro component to either element, and then assign the Text and Text Mesh Pro fields as shown below:

<< Third Party Support