OverrideDialogueUI not setting portraits

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Loremu
Posts: 20
Joined: Wed Dec 29, 2021 11:06 am

OverrideDialogueUI not setting portraits

Post by Loremu »

Hi,

I need help with two different issues that (I think) are both related to the OverrideDialogueUI Component.

Basic infos about the game:
It is a story based game about memories. In the entire game you are either in the village where you select memories that you want to see, OR you are within a memory. After finishing a memory you return to the village.
All memories follow the same structure. They mostly play out on a canvas that is layerd on top of the village. When starting a memory a prefab is instantiated and any changing data is read from a ScriptableObject (so - it's always the same prefab). When the memory is finished, the prefab instance is deleted. The village environment stays active all the time. There are no scene changes during the game.
The default Dialogue UI that the DialogueManager uses is called "CharacterComment_DialogueUI". This is used for dialogue in the village.

Within the memory there are some parts that use the dialogue system with the OverrideDialogueUI Component. The Dialogue UIs used in the memories are called "Comic_DialogueUI" and "MemoryComment_DialogueUI".

Issue 1
There is the option to show an intro before the game. The intro is a prefab that is instantiated in the scene and deleted after it is finished. Within the intro the Dialogue System is used. For debugging I implemented a toggle whether to show the intro or not. If set to false, the intro prefab is not instantiated and the game starts right away with the village view.

The issue is: When the intro is played, all following OverrideDialogueUI Components do not seem to work. The UIs "Comic_DialogueUI" and "MemoryComment_DialogueUI" do not show up and it uses the default UI instead ("CharacterComment_DialogueUI").

When setting the "show intro" toggle to false before starting play mode (so the intro prefab is not instantiated at all) everything works fine.

During the intro there are no changes (to my knowledge) to any settings of the DialogueManager. It just uses the Dialogue System with normal DialgoueSystemTriggers.
I tried calling DialogueManager.StopAllConversations() before and after Destroying the Intro Prefab Instance bc I thought maybe sth. is still running in the background but that did not solve the issue.

Issue 2 (This one is more important at the moment)
"MemoryComment_DialogueUI" (which is used with an OverrideDialogueUI within a Memory) should display a character portrait but it does not seem to work. I've tried following setups:
  • NO OverrideDialogueUI, so it uses the default "CharacterComment_DialogueUI": the portrait is displayed correctly.
  • OverrideDialogueUI uses a copy of the default "CharacterComment_DialogueUI": the placeholder portrait of the prefab is displayed.
  • "MemoryComment_DialgoueUI" set as default dialgoue UI and NO OverrideDialgoue UI in the Memory: portrait is displayed correctly.
  • OverrideDialogueUI uses "MemoryComment_DialogueUI" prefab: the placeholder portrait of the prefab is displayed.
  • OverrideDialogueUI uses "MemoryComment_DialogueUI" prefab in Village scene (so not in the instanced memory): the placeholder portrait of the prefab is displayed.
  • Used a OverrideDisplaySettings in the memory with "MemoryComment_DialogueUI": the placeholder portrait of the prefab is displayed.
So I think the UI itself is working but somehow the OverrideDialogueUI does not recognize the portraits.

--------------------------------------------------------
Sorry for the novel sized question. Any help is appreciated!
Thank you in advance!
Best
Lorena
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: OverrideDialogueUI not setting portraits

Post by Tony Li »

Hi Lorena,

Are you using the current version of the Dialogue System? If not, can you back up your project and then update to the current version (2.2.35 as of this reply).

When you use OverrideDialogueUI, do any warnings appear in the Console window?

Temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then play the scene and reproduce the issue. This should log a line like:

Dialogue System: Starting conversation 'title' with actor=XXX and conversant=YYY

Make sure XXX and YYY are the characters you expect.

At any point, please feel free to send me a reproduction project with reproduction steps if you'd like me to take a direct look.
Loremu
Posts: 20
Joined: Wed Dec 29, 2021 11:06 am

Re: OverrideDialogueUI not setting portraits

Post by Loremu »

Hi Toni,

Thank you for your quick response, the support is really top notch!

I am using the current version (2.2.35).

The additional Debug Messages were really helpful, the issue regarding the intro is solved now :D

The issue regarding the portrait is partially solved, but not completely.

I noticed that the actor is not assigned correctly, so I added a DialogueActor component to my Character_Comment_Outcome prefab. CharacterComment.cs assigns the .actor in Awake.
Now it shows the portrait of the correct character (so not the default placeholder portrait anymore). So that's the part of the issue that' solved now.

Issue
However, the actor/character has actually multiple portraits stored in the database (different facial expressions needed in different dialogue entries). I use [pic=3] in the dialogue text in the database to assign the portrait.

Again, this only works when NOT using an OverrideDialogueUI on the prefab but the default DialogueUI (called CharacterComment_DialogueUI) - then it assigns the correct portrait (portrait 3).
Yet, if I add the OverrideDialogueUI to the prefab it always shows portrait 1 (no matter which Dialogue UI prefab I use).

Info about the structure
Hope this is not too confusing, I'll try to make the structure a bit clearer:

During a memory, there are a lot of prefabs that assign stuff during runtime. At the moment the relevant one is "Character_Comment_Outcome.prefab". It holds following components:
- Rect Transform
- Character Comment Block (--> custom script)
- Dialogue Actor (with "Template Character" assigned as actor in the prefab --> is overwritten by CharacterCommentBlock in Awake.)
- Dialogue System Trigger (OnUse is called by CharacterCommentBlock in OnEnable via an Invoke() with a delay of 0,0001 seconds to make sure it is called after every other script's OnEnable bc I thought it might be an execution order issue)
- Dialogue System Events (only doing stuff OnConversationEnd)
- Override Dialogue UI (using the MemoryComic_DialogueUi.prefab)

The MemoryComic_DialogueUI prefab has placeholder stuff assigned (placeholder conversations and portraits) and when the Character_Comment_Outcome GameObject is SetActive in the Scene the CharacterComment script checks which conversation and entry should be played right now and assigns them to the DialogueSystemTrigger. It also assigns the .actor to the DialogueActor.

The point where I'm stuck
I have no idea how using the default UI is different to using the Override. The Debug Messages are the same for both versions, no matter if there is an OverrideDialogueUI on the prefab or not.(except for the Warning regarding the Alert messages but -correct me if I'm wrong - I think this always pops up when using a certain DialogueUI.prefab for the first time that does not use the alert stuff -> so I don't think it's related to the issue). Below are the messages starting from the frame when the prefab is SetActive (code display is just for better readability). If you need more information I can also send the entire log.

No OverrideDialogueUI on the prefab, using default DialogueUI (CharacterCommentDialogueUI):

Code: Select all

[14.04.2023 14:14:41] Dialogue System: Ending conversation.
[14.04.2023 14:14:41] Character Comment (CharacterCommentBlock) called Awake. dialogueActor.actor = Patrick
[14.04.2023 14:14:41] Dialogue System: Registering transform Character Comment as actor 'Patrick'.
[14.04.2023 14:14:41] Dialogue System: Dialogue System Trigger is firing OnUse.
[14.04.2023 14:14:41] Dialogue System: Starting conversation '01_Herrenrunde_Collection', actor=Character Comment (UnityEngine.RectTransform), conversant=Character Comment (UnityEngine.RectTransform).
[14.04.2023 14:14:41] Dialogue System: Character Comment says 'If I had known that this would happen eventually I might have acted differently. But - would it have made any difference at all?'
[14.04.2023 14:14:41] Dialogue System: Sequencer.Play( Delay(2.133333)@0 )
[14.04.2023 14:14:41] Dialogue System: Sequencer: Delay(2.133333)

OverrideDialogueUI on the prefab, using MemoryComment_DialogueUI:

Code: Select all

[14.04.2023 14:16:46] Dialogue System: Ending conversation.
[14.04.2023 14:16:46] Character Comment (CharacterCommentBlock) called Awake. dialogueActor.actor = Patrick
[14.04.2023 14:16:46] Dialogue System: Registering transform Character Comment as actor 'Patrick'.
[14.04.2023 14:16:46] Dialogue System: Dialogue System Trigger is firing OnUse.
[14.04.2023 14:16:46] Dialogue System: Starting conversation '01_Herrenrunde_Collection', actor=Character Comment (UnityEngine.RectTransform), conversant=Character Comment (UnityEngine.RectTransform).
[14.04.2023 14:16:46] Dialogue System: No UI text element is assigned to Standard Dialogue UI's Alert UI Elements.
[14.04.2023 14:16:46] Dialogue System: Character Comment says 'If I had known that this would happen eventually I might have acted differently. But - would it have made any difference at all?'
[14.04.2023 14:16:46] Dialogue System: Sequencer.Play( Delay(2.133333)@0 )
[14.04.2023 14:16:46] Dialogue System: Sequencer: Delay(2.133333)
Any ideas what could cause the issue and how to solve it?

Best,
Lorena
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: OverrideDialogueUI not setting portraits

Post by Tony Li »

Hi Lorena,

I think this might be the issue:

> - Dialogue Actor (with "Template Character" assigned as actor in the prefab --> is overwritten by CharacterCommentBlock in Awake.)

It may be that the Dialogue Actor is registering itself as the "Template Character" before the Awake method runs.

As a test, after your Awake method runs, in Start() disable and then re-enable the DialogueActor component. This will cause it to unregister itself and re-register itself under the correct actor name.

Alternatively, try a character whose Dialogue Actor field is set to the correct actor in the prefab, instead of setting it in Awake.

If either of those provide any insight, would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?
Loremu
Posts: 20
Joined: Wed Dec 29, 2021 11:06 am

Re: OverrideDialogueUI not setting portraits

Post by Loremu »

Hi Toni,

thanks for the response.
I tried your suggestion (disabling and re-enabling the DialogueActor Component) in different variations (in Awake, Start, OnEnable, right before triggering the dialogue). Unfortunately it did not work, so I cheatet my way around the issue by just assigning the MemoryComment_DialogueUI as the default UI and using an override for the CharacterComment_DialogueUI (this does not have any portraits anyway).

I'll check if I my institution's policies allow me to send a reproduction project. Could you provide some further information how the data is handled?

Thank you!
Best,
Lorena
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: OverrideDialogueUI not setting portraits

Post by Tony Li »

Hi,

Reproduction files are handled confidentially. I download the reproduction project into a sandbox virtual machine, examine it, and then delete the virtual machine (including the copy of your project) when the issue is resolved. As of this post, no one else has access to it. (I'm the only one handling reproduction projects.)
Loremu
Posts: 20
Joined: Wed Dec 29, 2021 11:06 am

Re: OverrideDialogueUI not setting portraits

Post by Loremu »

Hi,
Thank you for the information. I'll check if it's permitted. Would be really helpful indeed as my project keeps doing mysterious stuff...
Best,
Lorena
Loremu
Posts: 20
Joined: Wed Dec 29, 2021 11:06 am

Re: OverrideDialogueUI not setting portraits

Post by Loremu »

Hi,

I found a fix - posting it here in case ur interested or it gives you further clues as to what the problem might be and what a proper solution might look like. I kinda brute force the portrait now.

CharacterCommentBlock.cs :

Code: Select all

private void OnEnable()
    {
        RequestInfo(this);

        //select correct entry depending on playerHasChosen, choice and positiveOutcome
        CheckConversationEntry();

        string _portrait = "pic=" + PortraitNumber();
        DialogueManager.SetPortrait(scriptableMemory.mainCharacter, _portrait);

        //quick and dirty to make sure dialogueSystemTrigger.OnUse() is called after all other OnEnable functions 
        Invoke("TriggerDialogue", 0.001f);
        
        FinishBlock();

    }

Code: Select all

    private string PortraitNumber()
    {
        Conversation _conversation = dialogueDatabase.GetConversation(scriptableMemory.conversationName);
        DialogueEntry _entry = dialogueDatabase.GetDialogueEntry(_conversation.id, dialogueSystemTrigger.startConversationEntryID);

        //check if the dialogue text contains "pic=" and return any numbers that directly follow.
        Regex regex = new Regex(@"pic=(\d+)\]");
        Match match = regex.Match(_entry.DialogueText);

        return match.Groups[1].Value;
    }

I think the issue might be caused by messed up actors. Maybe I have mulitple objects in the scene with the same actor or sth. like that. But this does the trick for now :)

Best,
Lorena
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: OverrideDialogueUI not setting portraits

Post by Tony Li »

> Maybe I have mulitple objects in the scene with the same actor or sth. like that.

That could certainly cause this issue. For example, if you character prefab has a Dialogue Actor set to a generic stand-in actor and you instantiate it, it's possible that the instantiated copy will register itself with the Dialogue System under the generic stand-in actor's name. And when you change the Dialogue Actor's actor to a different actor, it won't re-register under the different actor's name (unless you disable and re-enable the Dialogue Actor component).
Post Reply