3D Model as a Portrait

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Wyldfire
Posts: 4
Joined: Fri Feb 12, 2021 7:00 pm

3D Model as a Portrait

Post by Wyldfire »

Hello all,

I'm considering getting this dialogue system for my project, and just looking into its capabilities. Has anyone done a 3D model as "portrait" with this, along the lines of:
https://cdn.wccftech.com/wp-content/upl ... -Labor.jpg

Even if the Dialogue System doesn't directly support it, I imagine it can be accomplished by just rendering the character over top of the dialog too. But I wanted to see if anyone's already explored ways to do that and had any pros and cons to share.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Model as a Portrait

Post by Tony Li »

Hi,

Yes. The Way of Wrath is a good example. For their portraits, they render 3D UMA characters to a render texture and then show those render textures in Raw Image components in the dialogue UI.

Wyldfire
Posts: 4
Joined: Fri Feb 12, 2021 7:00 pm

Re: 3D Model as a Portrait

Post by Wyldfire »

Perfect, that's exactly what I was hoping to be able to do! Thanks for the quick response, this asset looks perfect.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Model as a Portrait

Post by Tony Li »

Glad to help!
Wyldfire
Posts: 4
Joined: Fri Feb 12, 2021 7:00 pm

Re: 3D Model as a Portrait

Post by Wyldfire »

Hello again! I finally actually have my first model, bought Dialog System and I'm setting up a dialog test for this. I decided to try out a layout with the speaker on the left always, so I have a single Image pane, and I have my render texture material set as its image.

Since the render texture/its material aren't technically "Texture2D" I can't really use them as each character's "Portrait" in the usual way even if I wanted to. Additionally, I have a special camera and light I want to position on the speaker. So I don't think I can use the regular portrait system for this approach (though I'm brand new here so maybe I'm overlooking something!)

Is there a callback/hook I can use to setup my camera/light on the current speaker whenever it changes?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Model as a Portrait

Post by Tony Li »

Hi,

Here's an example:

DS_RenderTexturePortraitExample_2021-03-01.unitypackage

It uses this script to point the camera at each speaker's portrait model:

RenderTextureActor.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

/// <summary>
/// When this actor speaks, points a portrait camera at its portrait model.
/// The portrait model should be located outside of the main gameplay area.
/// The portrait camera should render to a RenderTexture that can be shown
/// in the dialogue UI.
/// </summary>
public class RenderTextureActor : MonoBehaviour
{
    public Camera portraitCamera;
    public Transform portraitCameraPosition;

    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.transform == this.transform)
        {
            portraitCamera.transform.position = portraitCameraPosition.position;
            portraitCamera.transform.rotation = portraitCameraPosition.rotation;
        }
    }
}
This script can move the camera every time a speaker changes. If you want to set it once at the start of the conversation instead, use OnConversationStart().
Wyldfire
Posts: 4
Joined: Fri Feb 12, 2021 7:00 pm

Re: 3D Model as a Portrait

Post by Wyldfire »

Awesome! That's exactly what I needed to know, and I was able to cobble something together that's working.

One more question if you don't mind; it may be that the below is all expected, but I wanted to check.

So, I had originally connected my Portrait UI Image filed to the "Portrait Image" field in "Standard UI Subtitle Panel". But, if I do that, Dialog System leaves the Image disabled. I assume because the Portrait data is so this seems reasonable. But does that mean that I need to be responsible for showing/hiding this UI element myself when it's called for? I did figure out that if it's the child of a panel or similar that Dialog System is going to show/hide anyway that the portrait comes along for the ride.

Anyway, if this is expected it's no big deal. I just want to make sure I'm starting out on a "Best Practices" path if I can :D
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: 3D Model as a Portrait

Post by Tony Li »

Hi,

Yes, that's all correct. If you assign it to the StandardUISubtitlePanel's Portrait Image field, the StandardUISubtitlePanel will be aware of it as the portrait image element, so it will show or hide it based on whether the speaker has a portrait sprite or not. In your case, I assumed you could leave it unassigned and inactive since you'd be using a Raw Image element for the 3D model instead.
Post Reply