Page 1 of 1
Multiple NPC dialogue UI
Posted: Fri Sep 27, 2019 9:33 am
by hellraider
So I have been tinkering with Dialogue System and especially 'textline'. It came to my attention that it there is only a single message template for NPC dialogue preventing to output messages of different NPCs in different styles.
Thinking 'Multiple NPC dialogue UI' extra would do the work I downloaded it just to realize that it only works with legacy UI.
My question is what would be the ideal solution to achieve this?
Re: Multiple NPC dialogue UI
Posted: Fri Sep 27, 2019 10:28 am
by Tony Li
Hi,
You can make a subclass of TextlineDialogueUI and override the GetTemplate() method. The current method looks like this:
Code: Select all
protected virtual StandardUISubtitlePanel GetTemplate(Subtitle subtitle)
{
return subtitle.speakerInfo.IsNPC ? conversationUIElements.defaultNPCSubtitlePanel : conversationUIElements.defaultPCSubtitlePanel;
}
It always uses the dialogue UI's default NPC subtitle panel. Override it to check for a custom subtitle panel:
Code: Select all
using PixelCrushers.DialogueSystem;
using UnityEngine;
public class MyCustomTextlineDialogueUI : TextlineDialogueUI
{
protected override StandardUISubtitlePanel GetTemplate(Subtitle subtitle)
{
var panelNumber = DialogueActor.GetSubtitlePanelNumber(subtitle.speakerInfo.transform);
if (panelNumber == SubtitlePanelNumber.Custom)
{
return subtitle.speakerInfo.transform.GetComponent<DialogueActor>().standardDialogueUISettings.customSubtitlePAnel;
}
else
{
return base.GetTemplate(subtitle);
}
}
}
Then you can add a Dialogue Actor component to an NPC, set Standard Dialogue UI Settings > Subtitle Panel Number to Custom, and assign a different subtitle panel template to use.
To retain UI element assignments when replacing the TextlineDialogueUI component with your new subclass, use the triple bar menu in the upper right of the Inspector to change to Debug mode. Then drag your new subclass script into the TextlineDialogueUI component's Script field.
Re: Multiple NPC dialogue UI
Posted: Sun Sep 29, 2019 3:57 pm
by hellwalker
Hi,
Thanks!
But is the TextlineDialogueUI correct class? I can't find that class anywhere in the project. When I try to create class you posted the TextlineDialogueUI is not recognized by visual studio or unity.
I also cannot find GetTemplate text when I search VS for string search on the entire solution.
my DS version is 2.2.0
Re: Multiple NPC dialogue UI
Posted: Sun Sep 29, 2019 4:06 pm
by Tony Li
Hi,
Since the original poster (is that you, too?) mentioned Textline, I assumed they already had the Textline framework imported into their project. Textline is available on the
Extras page. My post above specifically covers how to customize Textline to use multiple NPC templates.
If you only want to show different NPCs' text in different panels, you don't need Textline. You can use multiple panels as described in
this post.
Re: Multiple NPC dialogue UI
Posted: Sun Sep 29, 2019 4:28 pm
by hellwalker
Ah sorry!
I mistook it for my issue I posted few days ago.
https://www.pixelcrushers.com/phpbb/vie ... 209#p14209
The username is similar and I guess solution too so I didn't pay close attention
