Page 1 of 1

Portraits with response buttons when using multiple player characters

Posted: Sun Nov 04, 2018 10:54 am
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

Re: Portraits with response buttons when using multiple player characters

Posted: Sun Nov 04, 2018 11:41 am
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);
        }
    }
}

Re: Portraits with response buttons when using multiple player characters

Posted: Sun Nov 04, 2018 3:56 pm
by Snebjorn
Wow, that was absurdly fast - and exactly what I was looking for - you're the best!

/Snebjørn

Re: Portraits with response buttons when using multiple player characters

Posted: Sun Nov 04, 2018 4:19 pm
by Tony Li
Glad to help! :-)