How to change font in a conversation

Announcements, support questions, and discussion for the Dialogue System.
GDev_23
Posts: 15
Joined: Fri May 28, 2021 1:12 pm

How to change font in a conversation

Post by GDev_23 »

Hello there!

I'm sorry if the topic has been discussed before, but I am wondering how to change my font in a dialog entry within a conversation... I would like each choice the player makes to have a different font.

I tried to use <font>"Name of the font"</font> tags in the Dialog Text to call the fonts in my assets but it doesn't seem to work... I'm sure you can do that kind of change within a conversation, right?

Thanks!
User avatar
Tony Li
Posts: 20744
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change font in a conversation

Post by Tony Li »

Hi,

Use TextMesh Pro (see TextMesh Pro Support) and <font> tags.
GDev_23
Posts: 15
Joined: Fri May 28, 2021 1:12 pm

Re: How to change font in a conversation

Post by GDev_23 »

Hi Tony and thanks for your quick reply,

I activated TextMesh Pro in the Welcome Window and I put my fonts in the TextMesh Pro/Resources/Fonts & Material folder. I tried the <font> tags as in your link but it still doesn't work :(
Is there something more to do in order to get the fonts?
User avatar
Tony Li
Posts: 20744
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change font in a conversation

Post by Tony Li »

Hi,

That should do it. Make sure the TextMesh Pro <font> tag works outside of the Dialogue System first. Create a test TextMeshProUGUI, and set the Text value to something like:

This is the default font. <font="LiberationSans SDF">This is Liberation Sans.</font> Back to default.

Make sure the TextMeshProUGUI's Extra Settings > Rich Text checkbox is ticked. It should already be ticked by default.
GDev_23
Posts: 15
Joined: Fri May 28, 2021 1:12 pm

Re: How to change font in a conversation

Post by GDev_23 »

Hi Tony,

I am so close!

I used TextMesh Pro to convert the font and it works in Unity as a GUI but when I use the tags in my Dialog System, it doesn't... It only shows the text with the tags without showing the fonts (GorriSans). I attached an image of what I wrote in my Dialog System window... I'm not sure what I missed here!
Attachments
It is what I wrote in the Dialog System window
It is what I wrote in the Dialog System window
01.PNG (9.65 KiB) Viewed 720 times
User avatar
Tony Li
Posts: 20744
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change font in a conversation

Post by Tony Li »

Hi,

Are you sure the subtitle panel is using a TextMeshProUGUI component?
GDev_23
Posts: 15
Joined: Fri May 28, 2021 1:12 pm

Re: How to change font in a conversation

Post by GDev_23 »

Hi,

I tried to add the component TextMeshProUGUI in the subtitle panel but Unity doesn't seem to know what it is (it just want to add a new script)...

However, in the subtitle panel, it detects that TextMesh Pro is activated (I added an image to show you).
Is there something missing?
Attachments
02.PNG
02.PNG (47.37 KiB) Viewed 684 times
User avatar
Tony Li
Posts: 20744
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change font in a conversation

Post by Tony Li »

Hi,

The menu item to add a TextMeshProUGUI is confusingly UI > Text - TextMeshPro, not UI > TextMeshProUGUI.

Try adding a "Text - TextMeshPro" to your subtitle panel.
GDev_23
Posts: 15
Joined: Fri May 28, 2021 1:12 pm

Re: How to change font in a conversation

Post by GDev_23 »

Hi,

Ok so I added the TextMeshProUGUI object in the scene and added it in the Subtitle Panel... but even with that, it doesn't work when I call it in the dialog. Maybe I'm doing it wrong?

I must say that I am pretty new to this and it is very confusing :?

Is there a step-by-step way to do this?
Attachments
04.PNG
04.PNG (29.09 KiB) Viewed 673 times
03.PNG
03.PNG (9.43 KiB) Viewed 673 times
User avatar
Tony Li
Posts: 20744
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change font in a conversation

Post by Tony Li »

Hi,

Here's a step-by-step. You've already done some of these steps, so you can skip over them.

0. (Clean-up) Remove the StandardUISubtitlePanel component from your Dialogue Manager. You'll also want to remove the Text (TMP) that you added.

1. In Unity's Package Manager window, make sure the TextMesh Pro package is installed in your project.

2. In the Dialogue System's Welcome Window, tick the TMP_PRESENT checkbox. (To open the Welcome Window, select menu item Tools > Pixel Crushers > Dialogue System > Welcome Window.)

3. Assign the prefab 'Basic Standard Dialogue UI' to the Dialogue Manager GameObject's Display Settings > Dialogue UI field. You can find this prefab in the Project window in Plugins / Pixel Crushers / Dialogue System / Prefabs / Standard UI Prefabs / Basic.
  • When asked if you want to use the prefab or add an instance, select Add Instance.
4. In the Hierarchy window, expand Dialogue Manager > Canvas > Basic Standard Dialogue UI > Dialogue Panel > NPC Subtitle Panel.
  • Right-click on NPC Subtitle Panel to open the context menu. Select UI > Text - TextMeshPro. This will create a Text (TMP) child GameObject.
  • Drag the Text (TMP) GameObject up so it's just below the Subtitle Text GameObject.
  • Add a Layout Element component to the Text (TMP). Tick the Flexible Width checkbox.
  • Delete the Subtitle Text GameObject.
5. Inspect the NPC Subtitle Panel GameObject. Assign your newly-created Text (TMP) to the Subtitle Text field.
Post Reply