Non-Sprite Portrait work around?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
strangedissipation
Posts: 2
Joined: Fri Jan 14, 2022 11:38 pm

Non-Sprite Portrait work around?

Post by strangedissipation »

Hello,

I'm looking for a work-around that will allow my to use gameObjects as portraits as opposed to 'sprites'.

I'm using animated portraits created with Live2D. Basically, it's procedurally animated meshes. I was hoping there was a workaround to be able to automatically associate the animated gameObject (the live2d portraits) with the dialogue system actors.

I'm going to have a separate portrait manager running to be able to change portraits and their displayed animations on the fly (using animator layer weights) and was planning to do it with scene event function calls. I could change/manage the portraits the same way, but having to set a portrait through a scene event for every line in the game would be tedious. I'm hoping there is some pre-existing method that will tell my portrait manager who is speaking and give access to their various actor data.

Thanks!

-SD
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Non-Sprite Portrait work around?

Post by Tony Li »

Hi,

Two ways:

1. OnConversationLine
Add an OnConversationLine(Subtitle) method to a script on your Dialogue Manager GameObject. In it, you can check subtitle.speakerInfo and subtitle.listenerInfo. If you can't determine what portrait to display from the character's transform (e.g., subtitle.speakerInfo.transform), you can add a custom script to the character and use GetComponent(). Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // Example if you need to show a Live2D relative to a subtitle panel's position:
    DialogueActor dialogueActor;
    var subtitlePanel = DialogueManager.standardDialogueUI.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
    // (Show portrait relative to subtitlePanel. Can also check subtitle.speakerInfo.transform or .Name)
}
OnConversationLine is a general purpose method you can use whenever you need to do something with every line of dialogue. If you're only concerned about managing subtitle panels, you may prefer the next option which is more direct:


2. StandardUISubtitlePanel Subclass
Make a subclass of StandardUISubtitlePanel and override the SetContent method. Then use this subclass in place of StandardUISubtitlePanel (steps).

Code: Select all

public class Live2DSubtitlePanel : StandardUISubtitlePanel
{
    protected override void SetContent(Subtitle subtitle)
    {
        base.SetContent(subtitle);
        // (Code to show your Live2D portrait here.)
    }
}

You could also use render textures in your dialogue UI, which is a common approach to showing 3D models as portrait images as in this example scene on the Dialogue System Extras page.
strangedissipation
Posts: 2
Joined: Fri Jan 14, 2022 11:38 pm

Re: Non-Sprite Portrait work around?

Post by strangedissipation »

Thank you so much, these look like great solutions!
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Non-Sprite Portrait work around?

Post by Tony Li »

Glad to help! If you have questions about implementing any of them, just let me know.
Post Reply