Page 1 of 1

How to sync Name color with Subtitle color (TMP)

Posted: Sun Jan 10, 2021 1:00 pm
by Abelius
Hello,

I'd swear there was a thread about this, but I can't find it anymore, so here's mine...

I "just" need to make sure the NPC Name and NPC Subtltle Text TMP - Text (UI) components have the same color.

In Dialogue Actor there's an option to use a subtitle color, but there's not an equivalent for the character name, and I find that aesthetically unpleasing.

I tried synchronizing "Vertex Color" in every line change, but then I realized the color is applied "manually" by DS with a tag.

So, before I go to the extreme of extracting that tag from the subtitle text, I'd like to know if you have a better suggestion.

Also, could I suggest to just add a name/subtitle sync option to DS, please?

Thank you!

Re: How to sync Name color with Subtitle color (TMP)

Posted: Sun Jan 10, 2021 2:54 pm
by Tony Li
Hi,

How are you setting the NPC's subtitle color? Using a Dialogue Actor component on the NPC's GameObject?

If you, then you could get the Dialogue Actor's subtitle color in an OnConversationLine method and apply it to the portrait name. Example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class ApplySubtitleColorToPortraitName : MonoBehaviour // Add to Dialogue Manager
{
    public Color defaultNameColor = Color.white;

    void OnConversationLine(Subtitle subtitle)
    {
        var ui = DialogueManager.dialogueUI as StandardDialogueUI;
        DialogueActor dialogueActor;
        var panel = ui.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
        if (dialogueActor != null && dialogueActor.standardDialogueUISettings.setSubtitleColor)
        {
            panel.portraitName.color = dialogueActor.standardDialogueUISettings.subtitleColor;
        }
        else
        {
            panel.portraitName.color = defaultNameColor;
        }
    }
}

Re: How to sync Name color with Subtitle color (TMP)

Posted: Sun Jan 10, 2021 5:15 pm
by Abelius
Ah, I see.

Yeah, I'm using Dialogue Actor but also PlayMaker, so I ended up using that dirty trick of extracting the Hex color code from the Subtitle TMP and converting it to color, and apply it to the name TMP. It's more or less the same.

Only that your suggestion of using OnConversationLine event is better performance-wise. I'll modify it that way.

Thank you!

Re: How to sync Name color with Subtitle color (TMP)

Posted: Sun Jan 10, 2021 6:02 pm
by Tony Li
Glad to help!