Page 1 of 1

Best way to use multiple subtitle panels with same dialogue source

Posted: Tue Sep 07, 2021 5:30 am
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 709 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 709 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!

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

Posted: Tue Sep 07, 2021 8:57 am
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;

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

Posted: Tue Sep 07, 2021 10:11 am
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.

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

Posted: Tue Sep 07, 2021 10:57 pm
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?

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

Posted: Wed Sep 08, 2021 8:19 am
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(); }

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

Posted: Tue Sep 14, 2021 4:33 am
by golden1yaki
Thanks Tony! That's really clear

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

Posted: Tue Sep 14, 2021 8:12 am
by Tony Li
Glad to help!

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

Posted: Fri Sep 24, 2021 12:17 pm
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 638 times

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

Posted: Fri Sep 24, 2021 3:12 pm
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