Portraits with response buttons when using multiple player characters

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Snebjorn
Posts: 12
Joined: Sun Apr 17, 2016 4:33 pm

Portraits with response buttons when using multiple player characters

Post by Snebjorn »

Hi,

Have searched around on the forum and looked through source code, but haven't found any really useful solution, so going to ask here:

Is there a reasonably simple/clean way to include mini portraits for individual response buttons when responses from more than one player character are available?

My concrete use case is a game where the player controls a party consisting of several different characters (all marked as players in the dialogue database) and I would like to make it visible to the player which character is going to speak if that button is clicked.

Hope that makes sense - if not, I can throw together a quick visual mock-up of the thing I have in mind.

/Snebjørn
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Portraits with response buttons when using multiple player characters

Post by Tony Li »

Hi,

Here's an example: MenuButtonPortraitsExample_2018-11-04.unitypackage

Assuming you're using the Standard Dialogue UI, replace your StandardUIResponseButton with this custom subclass:

CustomResponseButton.cs

Code: Select all

using PixelCrushers.DialogueSystem;

public class CustomResponseButton : StandardUIResponseButton
{
    public UnityEngine.UI.Image image;

    private void OnEnable()
    {
        if (response != null)
        {
            var actor = DialogueManager.masterDatabase.GetActor(response.destinationEntry.ActorID);
            image.sprite = UITools.CreateSprite(actor.portrait);
        }
    }
}
User avatar
Snebjorn
Posts: 12
Joined: Sun Apr 17, 2016 4:33 pm

Re: Portraits with response buttons when using multiple player characters

Post by Snebjorn »

Wow, that was absurdly fast - and exactly what I was looking for - you're the best!

/Snebjørn
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Portraits with response buttons when using multiple player characters

Post by Tony Li »

Glad to help! :-)
Post Reply