Page 2 of 3

Re: Don't Disable Response Menu and Global Delay

Posted: Fri Feb 07, 2020 1:49 pm
by Tony Li
Hi,

I don't think you need to override ShowSubtitle. Instead, change the script with OnConversationLine to contain:

Code: Select all

private int lastSpeakerId = -1;

private void OnConversationStart(Transform actor)
{
    lastSpeakerId = -1;
}
    
private void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.id != lastSpeakerId && subtitle.dialogueEntry.id != 0)
    {
        const string delayCommand = "Delay(0.45)";
        subtitle.sequence = string.IsNullOrEmpty(subtitle.sequence)
            ? $"{delayCommand}; {{default}}"
            : $"{delayCommand}; {subtitle.sequence}";
        lastSpeakerId = subtitle.speakerInfo.id;
    }
}

Re: Don't Disable Response Menu and Global Delay

Posted: Fri Feb 07, 2020 3:23 pm
by bubucha
Well, that still doesn't help me with the issue - Delay only works after Response Menu, as in the video.

Re: Don't Disable Response Menu and Global Delay

Posted: Fri Feb 07, 2020 5:01 pm
by Tony Li
Oh! I think I understand now. You want the hide animation to play. Then you want to delay for a duration before the other character's panel plays its show animation. Is that correct?

If so, the easiest way to do that is to manually close the subtitle panel but still allow the sequence to run a little longer. You could use the SendMessage() sequencer command to tell the subtitle panel to close. For example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class HideDelayModifySequence : MonoBehaviour
{
    private int lastSpeakerId = -1;

    private void OnConversationStart(Transform actor)
    {
        lastSpeakerId = -1;
    }

    private void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.id != lastSpeakerId && subtitle.dialogueEntry.id != 0)
        {
            var ui = DialogueManager.dialogueUI as StandardDialogueUI;
            var panel = subtitle.speakerInfo.isNPC ? ui.conversationUIElements.defaultNPCSubtitlePanel : ui.conversationUIElements.defaultPCSubtitlePanel;
            var closeAndDelayCommand = $"SendMessage(Close,,{panel.name})@{{{{end}}}}; Delay(3)@{{{{end}}}}";
            subtitle.sequence = string.IsNullOrEmpty(subtitle.sequence)
                ? $"{closeAndDelayCommand}; {{default}}"
                : $"{closeAndDelayCommand}; {subtitle.sequence}";
            lastSpeakerId = subtitle.speakerInfo.id;
        }
    }
}
[EDIT: Fixed typo; added complete script]

Re: Don't Disable Response Menu and Global Delay

Posted: Fri Feb 07, 2020 6:20 pm
by bubucha
Yeah, you got the idea right.

I tried the code, but it, once again, does nothing.
I am not sure, but it is almost like ignored. I even tried to close the subtitle panels in ShowSubtitle, before calling base, but no effect. I can see them being closed and reopened, but still no delay.

Re: Don't Disable Response Menu and Global Delay

Posted: Fri Feb 07, 2020 7:56 pm
by Tony Li
There was a typo. I had "{{end}}" in the script. But since this is in a C# $"string", it interpreted the "{{" as a single {. I updated the script in my previous reply. Here's a full scene example:

DS_TestHideDelay_2020-02-07.unitypackage

Re: Don't Disable Response Menu and Global Delay

Posted: Sat Feb 08, 2020 2:08 pm
by bubucha
Thanks, I will try it tomorrow and let you know.

Re: Don't Disable Response Menu and Global Delay

Posted: Sat Feb 08, 2020 7:07 pm
by bubucha
So I tried it. Right now it closes the panel during the type. So... Yeah. Pretty much doesn't work.
I also tried setting up a Delay in the database directly in Sequence field, but it didn't produce any delays either.

Let's try to make it native through code. So that I can override a class and a method that works with delays and assign the logic there (if new speaker => Delay). Could you suggest me where do I start looking? Because overriding ShowSubtitles doesn't work, too. There is a lot happening during ConversationView class as I have seen. Perhaps it happens somewhere there?

Re: Don't Disable Response Menu and Global Delay

Posted: Sat Feb 08, 2020 8:17 pm
by Tony Li
I don't understand what doesn't work. Did you try the example scene?

Here's a copy of the example scene with longer text so you can see it type everything:

DS_TestHideDelay_2020-02-08.unitypackage


This is what it looks like:



The animation I used is a bit wonky, but you can see that it delays for 3 seconds before moving to the next subtitle (if the speaker changed).

Re: Don't Disable Response Menu and Global Delay

Posted: Sun Feb 09, 2020 3:57 pm
by bubucha
Hey, sorry for the delay.
Here is what is happening right now with the code you sent:
https://www.dropbox.com/s/nihp5tmrao1y3 ... e.mp4?dl=0

Something is getting broken in the middle. Can't really understand what exactly.

Re: Don't Disable Response Menu and Global Delay

Posted: Sun Feb 09, 2020 4:02 pm
by Tony Li
Let's see if we can narrow down the problem. Does the example that I sent you work the way you want it to?

If so, then we can focus on your scene.

If not, we can focus on the script.