Accumulate text in one place, but seperate portraits

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Accumulate text in one place, but seperate portraits

Post by NotVeryProfessional »

I've found the accumulate text function and the included templates that use it, but I can't get to work what I want for my game:

All text from all speakers should be accumulated together, so I can scroll through it. Like so:

Player: Hey, how are you?
Josh: I'm fine thank you.
Player: Hey, can I ask a question?
...

The WRPG template does that. However, it does it by having only one portrait, etc. I want them split, like in the basic or the VN template, to get this visuals:
dialog.jpg
dialog.jpg (74.97 KiB) Viewed 436 times
As you can see, my current attempt only shows one side of the conversation, because it's based on the VN template which has seperate subtitle panels for each participant, and that they point to the same text doesn't make it accumulate together.

How can I achieve my desired effect? (I also have a 2nd NPC subtitle panel, not visible here, just in case that makes a difference)
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Accumulate text in one place, but seperate portraits

Post by Tony Li »

Hi,

You can use a small subclass of StandardUISubtitlePanel to keep the text in sync. Here's an example scene:

DS_SharedSubtitleTextExample_2020-11-25.unitypackage

It's made in Unity 2020.1. The dialogue UI is based on the WRPG prefab.

And here's the script that's in the example package:

SharedTextSubtitlePanel.cs

Code: Select all

using PixelCrushers.DialogueSystem;
public class SharedTextSubtitlePanel : StandardUISubtitlePanel
{
    private StandardDialogueUI ui;

    protected override void Awake()
    {
        base.Awake();
        ui = GetComponentInParent<StandardDialogueUI>();
    }

    public override void SetContent(Subtitle subtitle)
    {
        base.SetContent(subtitle);
        foreach (var panel in ui.conversationUIElements.subtitlePanels)
        {
            panel.accumulatedText = accumulatedText;
        }
    }
}
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Accumulate text in one place, but seperate portraits

Post by NotVeryProfessional »

brilliant, I'll give that a try. Thanks!
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Accumulate text in one place, but seperate portraits

Post by NotVeryProfessional »

This almost works, but when the player is speaking, the NPC portrait is replaced with the player portrait (and the player portrait remains as well). Probably a small hickup in the code somewhere. I'll see if I can find it myself.
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Accumulate text in one place, but seperate portraits

Post by NotVeryProfessional »

Got it. The "PC Image" of the Response Panel was set up wrongly, pointing to the NPC image.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Accumulate text in one place, but seperate portraits

Post by Tony Li »

Thanks for catching that. I totally forgot to reassign the portrait image to the response panel. I just updated the example scene my previous reply so future readers will have a corrected version.
Post Reply