Change color of UI's for different actors in one conversation.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
SGanser
Posts: 2
Joined: Fri Apr 15, 2022 2:16 pm

Change color of UI's for different actors in one conversation.

Post by SGanser »

Hello,
I choosed the StandardUI Template for my Conversation and want to customize it.
What I need is that the background changes color depent on which actor is currently speeking. I have some conversations with more than one actors and want to appear them in different colors. I need something like:

Get the actor of the current conversation node.
Load the color from the actors field.
Set the color to the Background of the UI behind Text.


Sorry for my bad english, I am German. Thanks.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change color of UI's for different actors in one conversation.

Post by Tony Li »

Hi,

Here are two different ways to do that:

Without Scripting: Create multiple subtitle panels with different colors. Assign each one to the dialogue UI's Subtitle Panels list. Each one will have an element number in the Subtitle Panels list. This is its subtitle panel number. Then add a Dialogue Actor to each character's GameObject. If the character doesn't have a GameObject, you can create an empty GameObject. Set the Dialogue Actor's Dialogue UI Settings > Subtitle Panel Number to the panel that you want the character to use.

With A Little Scripting: In the Dialogue Editor's Actors section, set a Custom Node Color for each actor. Then add a script with an OnConversationLine() method to the Dialogue Manager. In the method, set the subtitle panel's color. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // Get actor' node color:
    Actor actor = DialogueManager.masterDatabase.GetActor(subtitle.speakerInfo.id);
    Color color = Tools.WebColor(actor.LookupValue("NodeColor"));
    
    // Get subtitle panel and set color:
    DialogueActor dialogueActor;
    var panel = DialogueManager.standardDialogueUI.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
    panel.panel.GetComponent<Image>().color = color;
}
SGanser
Posts: 2
Joined: Fri Apr 15, 2022 2:16 pm

Re: Change color of UI's for different actors in one conversation.

Post by SGanser »

Thank you, that's exactly what I need. I solved it with the script solution. A further question: How can I switch between screen and worldspace during conversation for a specific actor? So far I made a subtitle panel in my layout. I tried something like:

Code: Select all

DialogueManager.DisplaySettings.defaultCanvas = preferredCanvas;
But it doesn't to seem effect. Please help.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change color of UI's for different actors in one conversation.

Post by Tony Li »

Hi,

Can you please clarify?

Do you want one character to show its subtitles in a screen space subtitle panel and another character to show its subtitles in a world space subtitle panel?

Or do you want a single character to show some of its subtitles in a screen space panel and other subtitles in a world space panel?

In either case, you may use a mixture of Dialogue Actor components, [panel=#] markup tags, and/or C# calls to DialogueManager.standardDialogueUI.OverrideActorPanel().
Post Reply