Page 1 of 1

WRPG with distinct NPC and PC subtitles

Posted: Mon Jul 03, 2023 11:12 pm
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 :)

Re: WRPG with distinct NPC and PC subtitles

Posted: Tue Jul 04, 2023 7:56 am
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>";
        }
    }
}

Re: WRPG with distinct NPC and PC subtitles

Posted: Tue Jul 04, 2023 5:11 pm
by skuwid
Switching to the SMS template has helped - thanks :)

Re: WRPG with distinct NPC and PC subtitles

Posted: Tue Jul 04, 2023 5:29 pm
by Tony Li
Glad to help!