Don't Disable Response Menu and Global Delay

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Don't Disable Response Menu and Global Delay

Post 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;
    }
}
bubucha
Posts: 14
Joined: Thu Feb 06, 2020 10:22 am

Re: Don't Disable Response Menu and Global Delay

Post by bubucha »

Well, that still doesn't help me with the issue - Delay only works after Response Menu, as in the video.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Don't Disable Response Menu and Global Delay

Post 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]
bubucha
Posts: 14
Joined: Thu Feb 06, 2020 10:22 am

Re: Don't Disable Response Menu and Global Delay

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Don't Disable Response Menu and Global Delay

Post 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
bubucha
Posts: 14
Joined: Thu Feb 06, 2020 10:22 am

Re: Don't Disable Response Menu and Global Delay

Post by bubucha »

Thanks, I will try it tomorrow and let you know.
bubucha
Posts: 14
Joined: Thu Feb 06, 2020 10:22 am

Re: Don't Disable Response Menu and Global Delay

Post 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?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Don't Disable Response Menu and Global Delay

Post 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).
bubucha
Posts: 14
Joined: Thu Feb 06, 2020 10:22 am

Re: Don't Disable Response Menu and Global Delay

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Don't Disable Response Menu and Global Delay

Post 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.
Post Reply