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?
Multiple NPC dialogue UI
Re: Multiple NPC dialogue UI
Hi,
You can make a subclass of TextlineDialogueUI and override the GetTemplate() method. The current method looks like this:
It always uses the dialogue UI's default NPC subtitle panel. Override it to check for a custom subtitle panel:
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.
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;
}
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);
}
}
}
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.
-
- Posts: 112
- Joined: Tue Jan 19, 2016 11:37 pm
Re: Multiple NPC dialogue UI
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
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
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.
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.
-
- Posts: 112
- Joined: Tue Jan 19, 2016 11:37 pm
Re: Multiple NPC dialogue UI
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

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
