Page 1 of 2
How to change font in a conversation
Posted: Mon Feb 07, 2022 3:14 pm
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!
Re: How to change font in a conversation
Posted: Mon Feb 07, 2022 3:16 pm
by Tony Li
Hi,
Use TextMesh Pro (see
TextMesh Pro Support) and
<font> tags.
Re: How to change font in a conversation
Posted: Mon Feb 07, 2022 3:43 pm
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?
Re: How to change font in a conversation
Posted: Mon Feb 07, 2022 4:16 pm
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.
Re: How to change font in a conversation
Posted: Mon Feb 07, 2022 4:35 pm
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!
Re: How to change font in a conversation
Posted: Mon Feb 07, 2022 6:26 pm
by Tony Li
Hi,
Are you sure the subtitle panel is using a TextMeshProUGUI component?
Re: How to change font in a conversation
Posted: Tue Feb 08, 2022 9:30 am
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?
Re: How to change font in a conversation
Posted: Tue Feb 08, 2022 10:04 am
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.
Re: How to change font in a conversation
Posted: Tue Feb 08, 2022 10:44 am
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?
Re: How to change font in a conversation
Posted: Tue Feb 08, 2022 12:03 pm
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.