I think I've narrowed the specific issue down to the following:
If the player has a line in a conversation, the Subtitle Panel set to Default PC Subtitle Panel will always set its Portrait Image as whatever the default animation state is per the player's animator controller.
Even if the player doesn't have the first line in a conversation, the Dialogue Manager will briefly bring the Default PC Subtitle Panel to the front (for one frame) before the Default NPC Subtitle Panel.
Because the Default NPC Subtitle Panel does not assign an image to its Portrait Image child game object until 1 frame after the Default PC Subtitle Panel, the 'flash' of the player's Dialogue Portrait image issue occurs, even though the Default NPC Subtitle Panel is lower in the hierarchy and is in front of Subtitle Panel 1.
(The above assumes 'Visibility' is set to 'Always From Start' for the Subtitle Panels involved.)
Here's a frame-by-frame example of what I observed in game, where Subtitle Panel 1 is the Default PC Subtitle Panel and Subtitle Panel 2 is the Default NPC Subtitle Panel:
Frame 1:
The Dialogue Manager begins a conversation.
Frame 2:
Subtitle Panel 1's 'Portrait Image' child object is activated and sets its UI Image as the first frame of the default animation in the player's Animator Controller.
Subtitle Panel 1's 'Portrait Name' child object activates and displays the player character's name.
Subtitle Panel 0's Portrait Image and Portrait Name child game objects are not yet activated.
In the Hierarchy, Subtitle Panel 1 is higher than Subtitle Panel 0 (which means Subtitle Panel 0 would display on top of it, if it was showing anything.)
Frame 3:
Subtitle Panel 1's 'Portrait Image' child game object remains active, but 'Portrait Name' deactivates.
Subtitle Panel 0's 'Portrait Image' child game object activates, and we get an overlap between it and Subtitle Panel 1's Portrait Image as Subtitle Panel 2's Portrait Image fades in.
Frames 4 to 7-10:
Subtitle Panel 0's 'Portrait Image' child game object finishes fading in.
Once the portrait is faded in, Subtitle 0's 'Portrait Name' child game object activates, which displays the NPC's name.
Two other notes:
This issue does not occur in a conversation where the player has no lines of dialogue. (Presumably because Subtitle Panel 1 isn't assigning any images to its Portrait Image child game object.
This issue does not occur if I go into frame-by-frame mode before the conversation starts, and then advance frame-by-frame while the conversation begins until the first line of dialogue is finished displaying. (e.g.: I advance frame-by-frame in the brief period after an in-game trigger is hit but before the Dialogue Manager starts the conversation.)
So, two questions for you, Tony:
I'm assuming the specific order of operations in terms of how the Dialogue Manager opens Dialogue Panels is set in its script? (I've tried toggling every option I can think of in the Standard Panel UI Component on the Subtitle Panels themselves, but it didn't fix the issue.)
Is there a way to have the speaker's name (the Portrait Name child game object) activate and display immediately when the conversation starts? It seems to wait a quarter to half of a second after the line starts, and setting an action to activate it at 'On Open()' in the Subtitle Panel's Standard Subtitle UI Panel component doesn't seem to do anything
I've got a workaround in mind (simply making sure that all conversations where the player is involved has the player speaking the first line), but would appreciate your input on the above as your schedule permits. No rush at all.
> 1. I'm assuming the specific order of operations in terms of how the Dialogue Manager opens Dialogue Panels is set in its script?
For the most part, yes. But you can change it by making a subclass of StandardUISubtitlePanel and overriding behavior. Can you remind me why you're not setting Visibility to Always Once Shown?
> 2. Is there a way to have the speaker's name (the Portrait Name child game object) activate and display immediately when the conversation starts? It seems to wait a quarter to half of a second after the line starts, and setting an action to activate it at 'On Open()' in the Subtitle Panel's Standard Subtitle UI Panel component doesn't seem to do anything
By default, StandardUISubtitlePanel will activate and display them immediately. On the subtitle panels in your dialogue UI, are the OnOpen()/OnFocus()/etc. events doing something with the Portrait Name to hide or show them specially?
Sorry for the delay in replying, I took a week off for the holidays. To your comments:
> Can you remind me why you're not setting Visibility to Always Once Shown?
I'm using 'Always Once Shown' to avoid an issue where, for the player character's dialogue portrait, I would get one frame of their default portrait (default as set via the character's Animator Controller, to be clear) that would appear at the start of the conversation before switching to the dialogue portrait set via Sequencer Commands in that first conversation step. (e.g.: If 'Sally' is the main character and her default dialogue portrait is 'Normal,' but I have a conversation where the first line of her dialogue is supposed to be using an 'Angry' dialogue portrait, I would see a brief flash of her 'Normal' dialogue portrait right at the start of the conversation.
> (Paraphrasing you here) What are the Dialogue Panel's OnOpen/OnClose events doing?
I'll attach an image with a picture of what's set on the Player and NPC's dialogue panels. Despite having the Portrait Name part of the portrait set to activate OnOpen as well as OnFocus, there's still a half-second or so delay before the name appears after the first line of text appears in only that first dialogue step. I've also observed that the name disappears before the spoken text does when the conversation ends. Since this issue only impacts the first and last step in a conversation, I get the impression it's related to the overall order of operations related to how panels are open/closed when conversations start and finish.
Hope this provides some more insight.
Thanks!
Attachments
Example of Subtitle Panel 1's 'Standard UI Subtitle Panel' component.
DialogueSystem_DialoguePanelExample_01_010324.jpg (38.81 KiB) Viewed 59696 times
Would you please remind me -- are you using a [pic=#] markup tag in the first dialogue entry's text to set the portrait image, or are you using a SetPortrait() sequencer command. If you're using SetPortrait, is there any difference if you use [pic=#]?
Do all of your subtitle panels share the same Portrait Name? If so, you can clear those OnOpen(), OnFocus(), and OnUnfocus() events.
If it's still not working the way you want, can you send me reproduction steps or a reproduction project?
> How are you setting the dialogue portrait image?
I'm using animated dialogue portraits, so each step in a conversation has an AnimatorPlay() Sequencer Command that references the relevant portrait. (e.g.: If Sally is speaking a sad line, it will use a 'Sally - Sad' animation.)
> Do all of your subtitle panels share the same Portrait Name?
I'm using the VN Template Standard Dialogue UI prefab with some customizations, but I haven't renamed any of the Subtitle Panel elements. Both Subtitle Panel 1 and Subtitle Panel 2 have two child game objects, and both are named 'Portrait Image,' and 'Portrait Name.' Subtitle Panel 1 is set as the Default Player Subtitle Panel, while Subtitle Panel 2 is the Default NPC Subtitle Panel. I'll include a screenshot to show you the hierarchy. (You can ignore Subtitle Panel 2, as I'm not using it.)
Regarding repro steps, the best outline in this thread is my post from 12/23 that starts with 'Back with an update after doing some experiments' wherein I outline, frame by frame, the behavior I was observing.
If, after reading my reply here and re-reviewing my post in this thread from 12/23, nothing comes to mind, then I think we can put this aside for now as the issue, while not ideal, is not what I would consider major/game breaking in my case. (It's not ideal of course, but it's a minor graphical bug I could live with shipping if I'm unable to make further tweaks to get around it.)
Appreciate the input, as always.
Attachments
DialogueSystem_DialogueManagerHierarchy_010423.png (13.56 KiB) Viewed 59682 times
I appreciate the help, but unfortunately, I couldn't get it to work. For the time being, I've decided to swap out the UI and plan to revisit this challenge in the future.
Speaking of which, if I aim to orchestrate a dialogue between two NPCs, what settings should I adjust to ensure their portraits appear on distinct subtitle panels? As it stands, I've set up a conversation, but both characters seem to be utilizing the same Subtitle Panel 0.
Are you the same person as lcn_mc (e.g., just changed username)? I want to make sure I'm providing the right answers to the right people.
In any case, to orchestrate a dialogue between two NPCs, add Dialogue Actor components to the NPCs' GameObjects. Use empty GameObjects if the NPCs don't already have GameObjects. Then set the Dialogue Actor components' Dialogue UI Settings > Subtitle Panel Number. If you can't use Dialogue Actor components for some reason, use the SetPanel(actor, #) sequencer command in the conversation.