Page 1 of 1
Assign multiple portrait images to the subtitle panel?
Posted: Wed Jan 05, 2022 4:31 am
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!
Re: Assign multiple portrait images to the subtitle panel?
Posted: Wed Jan 05, 2022 8:59 am
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:
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.
Re: Assign multiple portrait images to the subtitle panel?
Posted: Fri Jan 28, 2022 1:10 am
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.
Re: Assign multiple portrait images to the subtitle panel?
Posted: Fri Jan 28, 2022 8:28 am
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.