Programmatic dynamic portrait and text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
NotSoup
Posts: 3
Joined: Mon Feb 17, 2025 6:18 am

Programmatic dynamic portrait and text

Post by NotSoup »

Hello!

I'm trying to get the dialogue system to work with item pick ups. Below is how I'd like it to work.
pickup.png
pickup.png (22.56 KiB) Viewed 1410 times
The 3 main parts that I'm iffy on the implentation of is

Format strings for each of the Dialogue entries - how is this done?

Item Portrait - I've currently got the Response Menu Panel's Potrait Image centered on the screen with a RenderTexture - but this is terrible, since I'd prefer conversation actors to be in their conversational positions, not in the middle of the screen. I can have the item as an actor in the conversation, which would give it a persistent position in the conversation, but again, I'd prefer not to move the actor potrait locations.

Item Portrait persistence - With the above implementation, the Potrait Image only appears during a response phase - ideally it should be visible for select dialogue entries, i.e. Panel 1 and 2 for observation, then pickup confirmation, then vanishing on being picked up.

An alternative implementation would be enabling/disabling a gameObject with a render texture like so, and listening to disable, but I'd prefer something that's more tightly tied to the conversation.

Code: Select all

    
    public void Interact()
    {
        Debug.Log($"Interacted with {_item.name}");
        itemPrefab = Instantiate(item.prefab, new Vector3(1000, 1000, 1000), Quaternion.identity);
        UIManager.ToggleItemPreviewQuad();
        DialogueManager.StartConversation("ItemPickup");
    }
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Programmatic dynamic portrait and text

Post by Tony Li »

Hi,

What if you point the camera at the item? Here's an example of what I'm talking about:

DS_ItemPickupExample_2025-02-17.unitypackage

It sets a Lua variable named Variable["object"], which the conversation and sequencer commands use via [var=object] markup tags. It uses the Camera() command to move the camera into position. You could always assign a camera to the Dialogue Manager's Sequencer Camera field and render that camera to a render texture if you prefer.
NotSoup
Posts: 3
Joined: Mon Feb 17, 2025 6:18 am

Re: Programmatic dynamic portrait and text

Post by NotSoup »

Hello! -

Thanks for the example and the help!
I've tried to apply the render texture solution like so - it hasn't been working on account of the Sequencer Camera disabling the main camera & making a clone, causing no display output - but I understand the overall intent for implementation. However, for objects that don't exist in the scene - for example if the player receives an item in a conversation, there'll be no ObjectCameraPos.
Screenshot 2025-02-18 101429.png
Screenshot 2025-02-18 101429.png (47.42 KiB) Viewed 1330 times
This would be similar to the observation implementation of Sorry We're Closed - which also uses the Dialogue Manager
Screenshot 2025-02-18 103232.png
Screenshot 2025-02-18 103232.png (689.32 KiB) Viewed 1330 times
The kind of implementation that I'm attempting to recreate is similar to the screenshot below.
Screenshot 2025-02-18 103717.png
Screenshot 2025-02-18 103717.png (244.28 KiB) Viewed 1330 times
For this implementation, a separate UI element is enabled, which is a render texture produced by a static camera in a part of the scene for specifically rendering item previews. The UI element then listens for the dialogue end event to close itself. It persists for three panels - a question, decision popup, and confirmation.

Maybe I'm taking the wrong approach - since the render texture only does one item at a time, would it be possible to add a Dialogue Panel that only contains one portrait image - the render texture, which will never need modifications in camera angle/placement, - that is set active for a ItemPreview boolean?
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Programmatic dynamic portrait and text

Post by Tony Li »

The Dialogue System Extras page has a RenderTexture Example (direct download) that might serve as a good model for this. It uses an extra camera that renders to a render texture and points to a special area of the scene set aside to view character portraits. In fact, for all I know Sorry We're Closed may have started from that example scene.
NotSoup
Posts: 3
Joined: Mon Feb 17, 2025 6:18 am

Re: Programmatic dynamic portrait and text

Post by NotSoup »

Thank you - I've taken a look at the example. It uses a RawImage Portrait element as a child to the Dialogue Panel to display the render texture- but it doesn't look like there's anything controlling it, it just appears as its parent is set active/inactive.

The solution I'll be applying is to use the RawImage Portrait specifically for an item preview, then have this toggled on and off programmatically based on the original interaction. This way the item preview will be decoupled from the dialogue, thus persistent, a render texture, doesn't modify the original conversation layout, and won't appear in a normal conversation.

If there's anything that seems wrong with this implementation - please let me know, before I dig myself deeper!, but otherwise, thank you!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Programmatic dynamic portrait and text

Post by Tony Li »

That sounds fine to me!
Post Reply