[SOLVED] Subtitle text colour resetting after being changed

Announcements, support questions, and discussion for the Dialogue System.
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Tony Li wrote: Tue Aug 10, 2021 9:49 pm When you change colors, can you also change the colors of the dialogue UI's Subtitle Text GameObjects? This should take care of the current line.
I can, but it looks like the Actor Subtitle Color component is changing the colour in the body of the text itself using "<color=xxxxxx>" rich text codes, so all I'm changing is the color on the TextMeshProUGUI, not the colour in the text.
Tony Li wrote: Tue Aug 10, 2021 9:49 pm I still don't know why the colors are being reset in the first place, but if you're happy with using ActorSubtitleColor then that's a fine way to go. If you do want to investigate why the colors are being reset, please let me know if the TextMeshProUGUI's color property is reset or if the text property ends up with <color> rich text codes around it.
When the colour was being reset on new conversation line, it was changing the TextMeshProUGUI component's colour property. No rich text codes in the text field. Whatever was causing it must be happening after OnConversationLine is being called, because I tried to add an event to change the colour back at each line but it didn't work. >.<


UPDATE: I've worked around the issue but having the Subtitle UI text component's text be replaced with the un-formatted subtitle text pulled from the dialogue entry. So my issue is more-or-less resolved, but I'm happy to keep providing any info you need to see if we can sort out the text colour being reset! :)
Last edited by Totem_Iain on Wed Aug 11, 2021 3:04 am, edited 1 time in total.
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Uploaded a video for you to see what's going on in the Subtitle Text object:

https://drive.google.com/file/d/1raHaBa ... sp=sharing
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle text colour resetting after being changed

Post by Tony Li »

Hi,

Thanks for the video. If you don't mind, I have a few questions:

Please open your dialogue database in the Dialogue Editor. In the Database section, what is the value of Database Properties > Emphasis Settings > Emphasis Setting 1 > Color? If it's set to white, what happens if you change it to a different color? Are you using emphasis markup tags (e.g., [em1])?

Does your dialogue UI's Subtitle Text GameObject have either of these components? StandardUIColorText or UITextColor.
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Tony Li wrote: Wed Aug 11, 2021 8:23 am Please open your dialogue database in the Dialogue Editor. In the Database section, what is the value of Database Properties > Emphasis Settings > Emphasis Setting 1 > Color? If it's set to white, what happens if you change it to a different color? Are you using emphasis markup tags (e.g., [em1])?
I am not using emphasis markup tags, no. Changing the colour of Emphasis 1 does not seem to change anything as far as I can tell.
Tony Li wrote: Wed Aug 11, 2021 8:23 am Does your dialogue UI's Subtitle Text GameObject have either of these components? StandardUIColorText or UITextColor.
It does not, no. It just has the StandardUISubtitlePanel component and a layout group.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle text colour resetting after being changed

Post by Tony Li »

Looking more closely at the video, I can see that the TextMeshProUGUI's Text property is wrapped in <color=#f5f5f5>, which is basically white. I'm not sure where that <color> tag is coming from. But when you switch to the Light Theme, you'll want to get rid of it.

After changing the color, try calling the StandardUISubtitlePanel's SetContent() method again. This will trigger the typewriter effect, so you may want to stop the typewriter and cause it to skip to the end:

Code: Select all

// Assumes 'panel' is a reference to the StandardUISubtitlePanel component.
panel.SetContent(DialogueManager.currentConversationState.subtitle);
panel.GetTypewriter().Stop();
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Tony Li wrote: Thu Aug 12, 2021 7:59 am Looking more closely at the video, I can see that the TextMeshProUGUI's Text property is wrapped in <color=#f5f5f5>, which is basically white. I'm not sure where that <color> tag is coming from. But when you switch to the Light Theme, you'll want to get rid of it.
That <color> tag is coming from the ActorSubtitleColor component on the actor GameObjects, I am assuming. It was not there before I added that component to the conversation actors.

Tony Li wrote: Thu Aug 12, 2021 7:59 am After changing the color, try calling the StandardUISubtitlePanel's SetContent() method again. This will trigger the typewriter effect, so you may want to stop the typewriter and cause it to skip to the end:

Code: Select all

// Assumes 'panel' is a reference to the StandardUISubtitlePanel component.
panel.SetContent(DialogueManager.currentConversationState.subtitle);
panel.GetTypewriter().Stop();
This is how I'm currently working around the problem. :) As you can see in the video, though, the <color> tags are the only thing keeping the colour correct, as it switches back to the old colour immediately after a new line is loaded. >.<
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle text colour resetting after being changed

Post by Tony Li »

The light theme should set the text to a dark color, but the <color=#f5f5f5ff> tag is light gray (almost white). Anyway, if you're using ActorSubtitleColor, you'll want to call the panel's SetContent() after updating the ActorSubtitleColor's color, so maybe you're taking the best approach right now. I realize you started using ActorSubtitleColor as a workaround for whatever it setting the TextMeshProUGUI's color property. I looked through the Dialogue System code, and I don't see anything that would set the color property, so maybe some other script is doing it.
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Tony Li wrote: Thu Aug 12, 2021 9:42 pm The light theme should set the text to a dark color, but the <color=#f5f5f5ff> tag is light gray (almost white). Anyway, if you're using ActorSubtitleColor, you'll want to call the panel's SetContent() after updating the ActorSubtitleColor's color, so maybe you're taking the best approach right now. I realize you started using ActorSubtitleColor as a workaround for whatever it setting the TextMeshProUGUI's color property. I looked through the Dialogue System code, and I don't see anything that would set the color property, so maybe some other script is doing it.
Correct, that's what should happen, and it does for the first line after the colour is changed (timestamp 0:40 in the video), however at the start of the next line it's changed back to the almost white dark theme colour (see the TextMeshProUGUI's Color property). It isn't my preference to use <color> tags at all, but the ActorSubtitleColor workaround is what's working for me right now. >.<

I don't know what other script could be causing it. I have tried stripping every other non-Dialogue System script form the template and it still happens. My best assumption that whatever is causing it is happening in a OnConversationLine event, because that's when the original colour is re-applied.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle text colour resetting after being changed

Post by Tony Li »

Hi,

Sorry, I've no idea how I forgot this. StandardUISubttilePanel does record the original text color and then reapply it with every line. It does this in case a previous line has used an [em#] emphasis tag to change the color.

The original color is in the protected property originalColor. To change it, make a subclass of StandardUISubtitlePanel. If you're already using a subclass, you can just update originalColor in your subclass. If you're changing the color from another script, you can add a method to your subclass that sets the color. Example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MySubtitlePanel : StandardUISubtitlePanel
{
    public void SetBaseColor(Color color) { originalColor = color; }
}
Then use your subclass in place of StandardUISubtitlePanel (see this post for tip) and call SetBaseColor() from your other script.
Totem_Iain
Posts: 14
Joined: Mon Jun 28, 2021 10:47 pm

Re: Subtitle text colour resetting after being changed

Post by Totem_Iain »

Tony Li wrote: Fri Aug 13, 2021 8:58 am Hi,

Sorry, I've no idea how I forgot this. StandardUISubttilePanel does record the original text color and then reapply it with every line. It does this in case a previous line has used an [em#] emphasis tag to change the color.

The original color is in the protected property originalColor. To change it, make a subclass of StandardUISubtitlePanel. If you're already using a subclass, you can just update originalColor in your subclass. If you're changing the color from another script, you can add a method to your subclass that sets the color. Example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class MySubtitlePanel : StandardUISubtitlePanel
{
    public void SetBaseColor(Color color) { originalColor= color; }
}
Then use your subclass in place of StandardUISubtitlePanel (see this post for tip) and call SetBaseColor() from your other script.
Aha, brilliant! I'll try out the subclass method and report back.
Post Reply