Setting dialogue line color with [panel] tag

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
suisei
Posts: 10
Joined: Tue Aug 22, 2023 7:45 am

Setting dialogue line color with [panel] tag

Post by suisei »

Currently I'm using [panel=#] tag to override default panel for speaker. Also I use DialogueActor to set text color.

I notice that if I use [panel] tag, the color setting is not working. I looked at the code:

Code: Select all

// StandardUISubtitleControls.cs
// line 439
        public override void ShowSubtitle(Subtitle subtitle)
        {
            	if (subtitle == null) return;
            	DialogueActor dialogueActor;
            	var panel = GetPanel(subtitle, out dialogueActor);  // Here dialogueActor is set
            
            	// (omit not relevant code)

		// Here actor used to adjust color
                if (dialogueActor != null && dialogueActor.standardDialogueUISettings.setSubtitleColor) 
                {
                    subtitle.formattedText.text = dialogueActor.AdjustSubtitleColor(subtitle);
                }
                SupercedeOtherPanels(panel);
                panel.ShowSubtitle(subtitle);
            }
        }

Code: Select all

// StandardUISubtitleControls.cs
// line 202
        public virtual StandardUISubtitlePanel GetPanel(Subtitle subtitle, out DialogueActor dialogueActor)
        {
            dialogueActor = null;
            if (subtitle == null) return m_defaultNPCPanel;

            // Check if we have a forced override:
            if (m_forcedOverridePanel != null) return m_forcedOverridePanel;

            // Check [panel=#] tag:
            var overrideIndex = subtitle.formattedText.subtitlePanelNumber;
            if (0 <= overrideIndex && overrideIndex < m_builtinPanels.Count)
            {
                var overridePanel = m_builtinPanels[overrideIndex];
                overridePanel.actorOverridingPanel = subtitle.speakerInfo.transform;
                return overridePanel;
            }

            // Check actor ID override:
            if (m_actorIdOverridePanel.ContainsKey(subtitle.speakerInfo.id))
            {
                var overridePanel = m_actorIdOverridePanel[subtitle.speakerInfo.id];
                overridePanel.actorOverridingPanel = subtitle.speakerInfo.transform;
                return overridePanel;
            }

            // Get actor's panel:
            var speakerTransform = subtitle.speakerInfo.transform;
            var panel = GetActorTransformPanel(speakerTransform, subtitle.speakerInfo.isNPC ? m_defaultNPCPanel : m_defaultPCPanel, out dialogueActor);
            return panel;
        }

Notice that in GetPanel() function if we have [panel] tag we will not reach GetActorTransformPanel() and actor will be null, so setting color in DialogueActor not works in this case.

Is it a bug? Can you advice some workaround for this?
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting dialogue line color with [panel] tag

Post by Tony Li »

Hi,

That's a bug. I'll post a fix by the end of the day.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting dialogue line color with [panel] tag

Post by Tony Li »

This patch should fix it:

DS_SubtitlePanelPatch_2023-10-09.unitypackage

This fix will also be in version 2.2.41.
suisei
Posts: 10
Joined: Tue Aug 22, 2023 7:45 am

Re: Setting dialogue line color with [panel] tag

Post by suisei »

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

Re: Setting dialogue line color with [panel] tag

Post by Tony Li »

Glad to help! Thanks for reporting the bug.
Post Reply