WRPG with distinct NPC and PC subtitles

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
skuwid
Posts: 6
Joined: Thu Jun 22, 2023 4:40 pm

WRPG with distinct NPC and PC subtitles

Post by skuwid »

Hi all, I am creating a dialogue system using the WRPG template and I am having some difficulty designing distinct NPC and PC subtitle styles - particularly it is the way the two players' messages stack vertically:

Image

In the screenshot, you can see the issue I'm having is that NPC text accumulates entirely on top of PC text, which accumulates below, as opposed to the two kinds of messages stacking alternately with each new line.

Here is my hierarchy:

Image

I have two separate TMP objects and Subtitle Panels, one for each character.

Here is the setup for my Standard Dialogue UI component:

Image

What do I need to revise in order to support both player subtitle styles, while ensuring that text accumulates properly?

Thank you :)
User avatar
Tony Li
Posts: 22124
Joined: Thu Jul 18, 2013 1:27 pm

Re: WRPG with distinct NPC and PC subtitles

Post by Tony Li »

Hi,

The WRPG template is designed to use a single subtitle panel that accumulates all conversation text in a single Text/TextMeshPro/SuperTextMesh element. If you want to use separate elements for the NPC and PC, consider using something like the SMS Dialogue UI template instead.

Or, to continue using the WRPG template, set it back to using a single subtitle panel and text element, and switch to using TextMesh Pro (see TextMesh Pro Support). Add a script to the Dialogue Manager that adds right-alignment rich text tags to player lines:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class RightAlignPlayerSubtitles : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        var text = subtitle.speakerInfo.formattedText.text;
        if (subtitle.speakerInfo.isPlayer && !string.IsNullOrEmpty(text))
        {
            subtitle.speakerInfo.formattedText.text = $"<align=\"right\">{text}<align>";
        }
    }
}
skuwid
Posts: 6
Joined: Thu Jun 22, 2023 4:40 pm

Re: WRPG with distinct NPC and PC subtitles

Post by skuwid »

Switching to the SMS template has helped - thanks :)
User avatar
Tony Li
Posts: 22124
Joined: Thu Jul 18, 2013 1:27 pm

Re: WRPG with distinct NPC and PC subtitles

Post by Tony Li »

Glad to help!
Post Reply