Dialogue Actor portrait and actor name not used until actor's first line

Announcements, support questions, and discussion for the Dialogue System.
DSUser9912
Posts: 3
Joined: Tue May 10, 2022 4:56 pm

Dialogue Actor portrait and actor name not used until actor's first line

Post by DSUser9912 »

Hi Tony,

In my game I create conversation in the dialogue editor with placeholder actors, by placeholder actors I mean I created 2 actors, "Player" and "NPC" with dummy display name "Player-Name" with dummy portrait (a banana image) and "NPC-Name" with dummy portrait (an apple image).

The reason for this is I want to override these placeholder actors' info by having a Dialogue Actor component assigned to each actual NPC (and my Player) in my game scene, and I have script to update the display name and portrait sprite field in the Dialogue Actor at run time (start of game) by using Player and NPC's real info (so that I don't have to go and find all of the sprites for each actor during conversation creation time, where some of the NPC sprites might not be created yet).

The dialogue UI I use is the Standard Dialogue UI, the prefab called OldSchool IIRC, with 2 Standard UI Subtitle Panels on each side, left side if NPC, right side is Player.

The issue I have here is, whenever I start a conversation through script by using the DialogueManager.Instance.StartConversation, pass in player's transform and NPC's transform, the portrait and display name is not updated, until actor's first line come up.

For example, if the conversation starts with the Player saying "Hi" first, then in the dialogue UI, the Player's display name and the portrait are set to what the Player's Dialogue Actor's actor name and portrait sprite is correctly, but the NPC's display name is still "NPC-Name" and the portrait is an apple. The NPC's name and portrait only get updated to what the Dialogue Actor defines on NPC's first line, for example, after Player says "Hi", NPC replies with "Hello", and that is when the NPC's display name and portrait get set to whatever the NPC's Dialogue Actor component defines.

Is there a way to update the Standard Dialogue UI to scan and use whatever the actor's Dialogue Actor defines on the beginning of the whole conversation, not at the time when actor's first line come up?

Thanks in advance.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Tony Li »

Hi,

Please use this patch:

DS_SubtitlePanelPatch_2022-05-10.unitypackage

This change will be in version 2.2.28 also.
DSUser9912
Posts: 3
Joined: Tue May 10, 2022 4:56 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by DSUser9912 »

Hi Tony, thanks for the reply,

I imported the patch but it didn't fix the issue. The portrait and display name in the UI is still the placeholder "NPC-Name" and an apple image. they get updated to the correct image until their first line.

I read your patch and I think the reason it didn't fix the issue is:

When the StandardDialogueUI.Open()is called, and it calls OpenSubtitlePanelsOnStartConversation ... all the way to CheckActorIDOnStartConversation method. It still tries to use this line
var actorTransform = GetActorTransform(actor.Name)
to find the actor transform.

However at this point, the actor.Name is the placeholder name "NPC-Name", therefore it cannot find the NPC object in the scene, and thus later in the same method, where it uses GetActorTransformPanel to find the Dialogue Actor component, it just returns at line189 because the speakerTransform object is null.

Hence in the patch where later you check if DialogueActor exists or not in OpenOnStartConversation, if it exists, you use the DialogueActor info won't work as it doesn't exist at that point.

I tried to update the code in StandardUISubtitleControls but didn't find a quick fix for this, the way it only uses actorID to find the actor's transform on start conversation will not work in my situation, it will always fail to find the actor transform unless I add 2 more parameters that explicitly pass in the transforms like the DialogueManager.Instance.StartConversation(conversationTitle, tranformPlayer, transformNPC) method, but that's out of my league as I only started to use Dialogue System...
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Tony Li »

Conversations can involve more actors than just the primary actor and conversant, so it wouldn't work to go by transforms. Instead, I recommend using CharacterInfo.RegisterActorTransform() to associate the correct GameObject with your generic actors before starting the conversation. Example:

Code: Select all

PixelCrushers.DialogueSystem.CharacterInfo.RegisterActorTransform("NPC-Name", someTransform);
PixelCrushers.DialogueSystem.CharacterInfo.RegisterActorTransform("Player-Name", someOtherTransform);
This way it will be able to find the correct GameObjects for "NPC-Name" and "Player-Name" and then show the actor name specified on the Dialogue Actor component.
DSUser9912
Posts: 3
Joined: Tue May 10, 2022 4:56 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by DSUser9912 »

Ah nice! RegisterActorTransform works! Thanks for the help!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Tony Li »

Glad to help!
Voltage3000
Posts: 14
Joined: Mon Nov 27, 2023 8:28 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Voltage3000 »

Hi Tony,

I was having pretty much the same issue as DSUser9912. I've tried the solution you suggested and found that it works pretty well for me.

The only issue I have is that the actor's name panel shows its internal name instead of its display name until the actor's first line plays.

Convo Start
convoStart.JPG
convoStart.JPG (316.69 KiB) Viewed 1517 times
First Line
firstLine.JPG
firstLine.JPG (296.28 KiB) Viewed 1517 times
How would I go about forcing the subtitle panel to update to the character's display name?

It would also be nice if I could access each subtitle panel's actor at the start of a convo. I would like to do things like change the portrait's background color based on which character is present.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Tony Li »

Hi,

Can you back up your project and update to the current version of the Dialogue System? Let me know if the issue is still present in the current version. It appears to correctly use the display names here in version 2.2.41.1.

To access each subtitle panel's actor at the start of the conversation, make a subclass of StandardUISubtitlePanel. (See How To: Replace Script with Subclass and Keep Field Assignments.) Override OpenOnStartConversation().
Voltage3000
Posts: 14
Joined: Mon Nov 27, 2023 8:28 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Voltage3000 »

Hi Tony,

Thanks for your help. Unfortunately, I'm working in Unity 2019.4.26f1. It seems that the latest version of the dialogue system does not support that version and the asset store is preventing me from downloading it into my project. We have attempted to upgrade to Unity 2020 in the past, but it did not go super smoothly so I'd rather avoid that if possible. I am currently on Version 2.2.30 of the dialogue system. I noticed that earlier in the thread you had a patch to download, but it said it would be included in version 2.2.28 though so I didn't bother with it. Is it worth it to try out that patch?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue Actor portrait and actor name not used until actor's first line

Post by Tony Li »

Hi,

Version 2.2.41.1 works fine with Unity 2019.4. That's the version I develop the Dialogue System with, although I also test it with all versions after that, too. The issue with the Asset Store is that the asset uploading tool no longer works with Unity 2019, so I had to upload it to the store using 2020.

You can install Unity 2020 or higher to download DS version 2.2.41.1 and then import the downloaded unitypackage into your Unity 2019 project. You can find the package in [AppData]\Roaming\Unity\Asset Store-5.x\Pixel Crushers.
Post Reply