Assign multiple portrait images to the subtitle panel?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
mamaga2874
Posts: 2
Joined: Wed Jan 05, 2022 4:21 am

Assign multiple portrait images to the subtitle panel?

Post by mamaga2874 »

Hey there,

I haven't been able to find a solution here yet; maybe someone can help me a little:

Is it possible to assign multiple portrait images in the standard UI subtitle panel? To put my question in concrete terms: I would like to use one portrait slot for the body of each actor and the other for different facial expressions.

Thank you!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assign multiple portrait images to the subtitle panel?

Post by Tony Li »

Hi,

Here are two ways you could do this:

1. With a bit of scripting: Make a subclass of StandardUISubtitlePanel. Override SetContent() and SetPortraitImage(). You could, for example:
  • In the Dialogue Editor, set the actor's portrait 1 to the base body image.
  • Set portraits 2+ to the facial expression images.
  • Use [pic=#] markup tags or SetPortrait() sequencer commands to set the portrait to 2+.
  • Add a child UI Image to the subtitle panel's Portrait Image.
  • In your subclass's SetContent(), set the Portrait Image's sprite to the base body image.
  • In SetPortraitImage(), set the child Image to whatever sprite (facial expression) is passed to it.
If you need a hand with that, let me know. Roughly, the script would look like:
Example without error checking for brevity

Code: Select all

public class MySubtitlePanel : StandardUISubtitlePanel
{
    public override void SetContent(Subtitle subtitle)
    {
        var actor = DialogueManager.masterDatabase.GetActor(subtitle.speakerInfo.id);
        portraitImage.sprite = actor.GetPortraitSprite(); // Set the base body image.
        base.SetContent(subtitle);
    }
    
    protected override void SetPortraitImage(Sprite sprite)
    { // Set face sprite:
        portraitImage.transform.GetChild(0).GetComponent<Image>().sprite = sprite;
    }
}
2. Or set up animated portraits.
mamaga2874
Posts: 2
Joined: Wed Jan 05, 2022 4:21 am

Re: Assign multiple portrait images to the subtitle panel?

Post by mamaga2874 »

Hello,

first off, thank you for your helpful answer. I followed your first suggestion, which works perfectly with the markup tags. To have the expression stay over a longer period of time, I decided to use the SetPortrait() sequencer command. But now I am facing problems doing so.

As I am using SetPortrait() sequencer, the given portrait (facial expression) replaces the base body image of the following dialog entries.
Attachments
SetPortrait.png
SetPortrait.png (24.45 KiB) Viewed 248 times
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assign multiple portrait images to the subtitle panel?

Post by Tony Li »

Hi,

You'll either need to:

1. Write a custom sequencer command that implements code similar to SetPortait() but changes the face image,

2. Or use animated portraits.

This kind of setup usually uses animated portraits, so I suggest investigating that option. Your portrait animations can change the sprite that is assigned to the facial expression image.
Post Reply