Page 1 of 1

3D Model as a Portrait

Posted: Fri Feb 12, 2021 7:06 pm
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.

Re: 3D Model as a Portrait

Posted: Fri Feb 12, 2021 7:56 pm
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.


Re: 3D Model as a Portrait

Posted: Fri Feb 12, 2021 7:59 pm
by Wyldfire
Perfect, that's exactly what I was hoping to be able to do! Thanks for the quick response, this asset looks perfect.

Re: 3D Model as a Portrait

Posted: Fri Feb 12, 2021 8:02 pm
by Tony Li
Glad to help!

Re: 3D Model as a Portrait

Posted: Mon Mar 01, 2021 8:53 pm
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?

Re: 3D Model as a Portrait

Posted: Mon Mar 01, 2021 10:39 pm
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().

Re: 3D Model as a Portrait

Posted: Tue Mar 02, 2021 2:51 pm
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

Re: 3D Model as a Portrait

Posted: Tue Mar 02, 2021 3:04 pm
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.