Textline Pre-Delay Icon Not Activating

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
tengolino
Posts: 5
Joined: Sat Jul 27, 2019 9:33 am

Textline Pre-Delay Icon Not Activating

Post by tengolino »

Hi Tony,

Thanks for all your work and thanks in advance for this question :)

Context
- I'm using Textline UI package
- I have a custom Delay Icon
- NPC delay is set to based on text length
- I have a part of the conversation that is the NPC speaking for a few nodes (see img below)
Screenshot_2.png
Screenshot_2.png (19.53 KiB) Viewed 187 times


Question/Problem
- What I was expecting was that before each NPC line, the delay icon would appear
- What is actually happening is that - sometimes the delay icon would not be set active


Would this be an issue with a bunch of NPC lines linked together? And the subtitle logic doesn't check between each line/entry because it's still the same speaker?

Thanks for your help again!

Best,
Tengolino

(Subtitle Settings)
Screenshot_3.png
Screenshot_3.png (26.76 KiB) Viewed 187 times
Screenshot_4.png
Screenshot_4.png (96.82 KiB) Viewed 187 times
tengolino
Posts: 5
Joined: Sat Jul 27, 2019 9:33 am

Re: Textline Pre-Delay Icon Not Activating

Post by tengolino »

Here's a video showing the problem.
(Ignore the multiple Delay Icon - I have multiple conversations)

As you can see, the delay icon shows up in the beginning, and later on when the Actors swapped, but not in between the dialogue entries from the NPC.

User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Textline Pre-Delay Icon Not Activating

Post by Tony Li »

Hi,

Try setting your template subtitle panels' Visibility to Only During Content.

If that doesn't help, can you send a reproduction project to tony (at) pixelcrushers.com? I'm not sure how to reproduce the issue. If I add a string of NPC nodes to Textline's example conversation, it shows the pre-delay icon for each node. So there's probably some small difference in the configuration.

(BTW, DS version 2.2.12+ comes with an SMS Dialogue UI prefab. You might prefer it to the Textline project. They run almost exactly the same code, though.)
tengolino
Posts: 5
Joined: Sat Jul 27, 2019 9:33 am

Re: Textline Pre-Delay Icon Not Activating

Post by tengolino »

Hi Tony, thanks for your fast response!

I'm embarrassed at how long I spent trying to figure this out - but I got it to work. I'll share it here in case anyone else will find this useful, and maybe Mr. Li can give us some more programming pointers here he he. :geek: :)

1. Alright let's start with The issue:
- The delay icon was not being Set Active at the correct interval between the NPC dialogue.
- It should be between messages (entries but in SMS UI), but sometimes it would be right before the message is shown
- Other times, it would be just be inactive between NPC messages

What was even more weird - the delay which is tied to the logic that Sets the Delay Icon active, was working fine.

This lead me on a Dialogue System journey and I found the coroutine below that should be doing the job.

(5 hours later...feeling like a complete Buffoon)

Suddenly - a lightbulb turned on. Wait a minute... coroutines.. asynchronous... overlapping... of course!

Code: Select all

protected virtual IEnumerator AddMessageWithPreDelay(float preDelay, Subtitle subtitle)
        {
            isInPreDelay = true;
            var preDelayIcon = subtitle.speakerInfo.isNPC
                ? npcPreDelaySettings.preDelayIcon
                : pcPreDelaySettings.preDelayIcon;
            Tools.SetGameObjectActive(preDelayIcon, true);
            //other code
            yield return new WaitForSeconds(preDelay);
            //other code
            Tools.SetGameObjectActive(preDelayIcon, false);
            AddMessage(subtitle);
            isInPreDelay = false;
            yield return null;
        }
2. Now for the investigation... (aka clicking on every variable in debugger until something makes sense)

So after some debugging, I found that the preDelay calculation is (sound obvious now...) based off of the length of characters, ADDED to additional delay seconds (a TextlineUI/SMS UI specific parameter) -- the preDelay can vary a lot compared to the standard {{end}} value. (code below)

Code: Select all

            public float GetDelayDuration(Subtitle subtitle)
            {
                return (basedOnTextLength ? Mathf.Max(DialogueManager.DisplaySettings.subtitleSettings.minSubtitleSeconds,
                    subtitle.formattedText.text.Length / Mathf.Max(1, DialogueManager.DisplaySettings.subtitleSettings.subtitleCharsPerSecond)) : 0) +
                    additionalSeconds;
            }
Therefore, using Delay{{{end}}} were missing and overlapping with each of the AddMessageWithPreDelay coroutine life span.

Also, becasue isInPreDelay is a shared bool inside the main SMS UI class, overlapping routines would be switching it on and off. And since isInPreDelay guards against showing response before delay is over, the responses were seemingly showing up randomly.

3. Finally... the solution

So... the solution was really simple. So I'm conflicted after spending so much time on it :lol:

I just added to the {{{end}}} sequence a @2. And added the following as the default sequence (in Dialogue System controller).

Code: Select all

{{{end}}}@2
Maybe Tony can verify/explain a bit more... but I think it's just because it offsets the extra additions to the GetDelayDuration method in SMS UI, compared to the default {{end}}. And the entries needed to be offset a bit to make sure that each delay sequence encompasses the entirety of each entry's coroutine (lest one suffer the fate of mismatched coroutine spaghetti fiasco).

Anyway, here's a short video I made to put some levity on what was otherwise a dark time debugging.. but ofc, most importantly - to thank Tony for his dedicated and thankless hard work supporting us here <3

User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Textline Pre-Delay Icon Not Activating

Post by Tony Li »

Yikes! Sorry about that lengthy debugging session. Thanks for the detailed explanation. I'll fix that coroutine timing issue in the next update.

Thanks for the video. I actually chuckled out loud a couple of times. :-)
Post Reply