Tips for dynamic UI panels

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hidingso
Posts: 26
Joined: Sat Sep 25, 2021 2:07 pm

Tips for dynamic UI panels

Post by hidingso »

Hi Tony, hope you are doing great!

I have some doubts about how to implement my dialogues for my needs. What I am looking for:
  • Screen-Space Bubble panel that follows an actor is the default UI.
  • When the actor whispers/shouts/thinks, change the panel image accordingly.
  • During cutscenes, the ability to switch to "narrator" panels that appear on the top left and right corners of the screen, without following any actor. This would be used if the actor does not appear on camera during dialogue.
  • If possible, animate each panel differently (opening and closing differently)
Currently, I am using "Custom" as the subtitle panel number for each actor with Bubble Panel as a child of the actor object. This way I can assign the follow target for the panel correctly.

I was looking at using the Basic Standard Dialogue UI with different panels (and changing them using SetPanel or markup), but I don't know if that's the correct way of doing it since I cannot assign any follow targets that way.

What would be the best way to approach this?
User avatar
Tony Li
Posts: 21972
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tips for dynamic UI panels

Post by Tony Li »

Hi,

The Dialogue Manager always points to a main dialogue UI which is typically a standard screen space UI such as Basic Standard Dialogue UI. Use this dialogue UI and its default NPC subtitle panel for your narrator.

Your idea to add different screen space bubble panels to this dialogue UI may work. Try this:

1. Add this UIFollow script to the bubble panel. Set its Container field to the main canvas GameObject. Set its UI field to the bubble panel itself. Leave the Follow This field unassigned for now.

2. Make a subclass of StandardUISubtitlePanel, and apply the subclass to the bubble panel instead of the base StandardUISubtitle Panel. (Info: applying in place) Override the SetContent() method to assign Follow This. Something like:

Code: Select all

public override void SetContent(Subtitle subtitle)
{
    base.SetContent(subtitle); // EDIT: Added this line. Had initially forgotten it.
    GetComponent<UIFollow>().followThis = subtitle.speakerInfo.transform.
}
3. Use SetPanel() or [panel=#] markup tags as normal.
hidingso
Posts: 26
Joined: Sat Sep 25, 2021 2:07 pm

Re: Tips for dynamic UI panels

Post by hidingso »

I tested this out and seems to solve the issue perfectly! You are a legend!

Initially, the bubble panel was empty, but I forgot to call the base SetContent() from my custom class. So the complete class:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;

public class MyCustomSubtitleUIPanel : StandardUISubtitlePanel
{
    public override void SetContent(Subtitle subtitle)
    {
        GetComponent<UIFollow>().followThis = subtitle.speakerInfo.transform;
        base.SetContent(subtitle);
    }
}
User avatar
Tony Li
Posts: 21972
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tips for dynamic UI panels

Post by Tony Li »

Thanks for pointing that out. I updated my previous post to fix that.
Post Reply