Best way to use multiple subtitle panels with same dialogue source

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Best way to use multiple subtitle panels with same dialogue source

Post by golden1yaki »

Hello,

I am trying to make an minimizable dialogue UI that players can expand or shrink it anytime. And it's not easy to make it responsive in Unity UI because the big one and the small one have different layouts. So I think it would be better to just using two individual UIs.

The two UIs would be like:
Small One:
Screen Shot 2021-09-07 at 17.15.17.png
Screen Shot 2021-09-07 at 17.15.17.png (16.76 KiB) Viewed 1016 times
Big One:
Screen Shot 2021-09-07 at 17.04.39.png
Screen Shot 2021-09-07 at 17.04.39.png (13.74 KiB) Viewed 1016 times
Whenever it expands or shrinks, the selected UI will show up displaying the ongoing dialogue, and another would just hide. But I couldn't figure out how do it.
(I am using StandardDialougeUI, StandardUISubtitlePanel, and StandardUIMenuPanel with little customizations.)

I've tried adding StandardDialougeUI to both UIs and using a script to switch them. But it seems like assigning DialogueManager.DialogueUI a new value wouldn't work while the conversation is running. I also tried adding SubtitlePanel to conversationUIElements.subtitlePanels but no luck either.

Is there a way to use multiple subtitle panels that shares same dialogue source?

Thanks in advance!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to use multiple subtitle panels with same dialogue source

Post by Tony Li »

Hi,

It may be easiest to use the same UI and get the anchoring to work correctly in both orientations (big and small).

However, if you want to use them as two separate windows, you could either make them two separate sets of (subtitle panel + menu panel) in the same dialogue UI, or as two separate dialogue UIs. In either case, when you switch, you'll need to manually copy the content from old to new. To copy the accumulated subtitle text, set the subtitle panel's accumulatedText property.

To change dialogue UIs in the middle of a conversation, you must set the current conversation view's dialogueUI. Example:

Code: Select all

DialogueManager.conversationView.dialogueUI = newUI;
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Re: Best way to use multiple subtitle panels with same dialogue source

Post by golden1yaki »

Thanks Tony! That's a really good advice and I'll give it shot to see if I can get the responsive UI to work. Otherwise I'll take the harder approach you suggest.
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Re: Best way to use multiple subtitle panels with same dialogue source

Post by golden1yaki »

Hi Tony,

I was wondering is it possible to display one dialogue on two separate dialogue UIs (or one dialogue UI with two subtitle /menu panels) and have them running at the same time?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to use multiple subtitle panels with same dialogue source

Post by Tony Li »

Hi,

I think so, with a little scripting. You could make a subclass of StandardUIDialogueUI or add a script with OnConversationStart/Line/ResponseMenu/End methods, such as:

Code: Select all

public StandardDialogueUI otherUI;

public void OnConversationStart(Transform actor) { otherUI.Open(); }

public void OnConversationLine(Subtitle subtitle) { otherUI.ShowSubtitle(subtitle); }

public void OnConversationResponseMenu(Response[] responses)
{
    otherUI.ShowResponses(DialogueManager.currentConversationState.subtitle, responses, DialogueManager.displaySettings.inputSettings.responseTimeout);
}

public void OnConversationEnd(Transform actor) { otherUI.Close(); }
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Re: Best way to use multiple subtitle panels with same dialogue source

Post by golden1yaki »

Thanks Tony! That's really clear
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to use multiple subtitle panels with same dialogue source

Post by Tony Li »

Glad to help!
dogEleven
Posts: 2
Joined: Sat Mar 13, 2021 2:50 am

Re: Best way to use multiple subtitle panels with same dialogue source

Post by dogEleven »

There are no"DialogueManager.currentConversationState"and"DialogueManager.displaySettings" now?
截屏2021-09-25 上午12.17.13.png
截屏2021-09-25 上午12.17.13.png (71.08 KiB) Viewed 945 times
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best way to use multiple subtitle panels with same dialogue source

Post by Tony Li »

Hi,

Did you include:

Code: Select all

using PixelCrushers.DialogueSystem;
at the top of your script?

Here's the API reference:

DialogueManager.currentConversationState
Post Reply