Page 1 of 1

Show continue button ONLY at end of conversation

Posted: Thu Nov 26, 2020 3:21 am
by NotVeryProfessional
I'd like to make all of my conversations end only when the player clicks the "continue" button. I don't want that button to show up otherwise, only at the end of conversations.

I couldn't find an option or a sequencer command to do that. I understand how to turn it on and off, but I'm looking for something like a global setting in the Dialog Manager. Does it exist and I just missed it?

(why? because I want that the player has the option to read back through the conversation, or think about it or whatever he wants before gameplay continues. It shouldn't go automatically back to gameplay. Maybe the player is a slow reader or something.)

Re: Show continue button ONLY at end of conversation

Posted: Thu Nov 26, 2020 8:00 am
by Tony Li
Hi,

There's no built-in option. But you can add a script to the Dialogue Manager to set the continue button mode. Something like:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class RequireContinueButtonOnLastNode : MonoBehaviour
{
    private bool isFirstNode = false;
    
    void OnConversationStart(Transform actor) { isFirstNode = true; }
    
    void OnConversationLine(Subtitle subtitle)
    {
        var isLastNode = !DialogueManager.currentConversationState.hasAnyResponses;
        if (isLastNode)
        {
            // Turn on continue button mode on last node:
            subtitle.sequence = "SetContinueMode(true); " + subtitle.sequence;
        }
        else if (isFirstNode)
        {
            // Turn off continue button mode when conversation starts:
            subtitle.sequence = "SetContinueMode(false); " + subtitle.sequence;
            isFirstNode = false;
        }
    }
}

Re: Show continue button ONLY at end of conversation

Posted: Tue Dec 01, 2020 3:52 am
by NotVeryProfessional
Finally got around to testing this and it seems to be working well... mostly.

It does seem to skip the first line of dialog (it appears, but instantly, no typewriter effect or waiting, I'll have to try with audio/voice file to check if that has an effect). It also shows up when the last conversation line is the player picking a dialog option (usually some variation of "thanks, goodbye"), which I didn't think about.

I'll be thinking about this again. I can go from here, I think. Checking if the speaker is the player should take care of my new problem, I think. The skipping is maybe an artifact of setting the continue mode?

Re: Show continue button ONLY at end of conversation

Posted: Tue Dec 01, 2020 10:56 am
by Tony Li
Hi,

For the case where the last node is a player option, you can change this:

Code: Select all

if (isLastNode)
to this:

Code: Select all

if (isLastNode && Subtitle.speakerInfo.isNPC)
There could be different reasons for the first line skipping. One solution is to change this line:

Code: Select all

subtitle.sequence = "SetContinueMode(false); " + subtitle.sequence;
to this:

Code: Select all

subtitle.sequence = "SetContinueMode(false); Delay({{end}}); " + subtitle.sequence;
This will delay for a duration based on the text length.

Re: Show continue button ONLY at end of conversation

Posted: Wed Dec 02, 2020 2:37 am
by NotVeryProfessional
works brilliantly, thanks.

Just one fix:

Code: Select all

if (isLastNode && Subtitle.speakerInfo.isNPC)
should be:

Code: Select all

if (isLastNode && subtitle.speakerInfo.isNPC)

Re: Show continue button ONLY at end of conversation

Posted: Wed Dec 02, 2020 5:55 am
by NotVeryProfessional
That works wonderfully. Thank you so much!

Re: Show continue button ONLY at end of conversation

Posted: Wed Dec 02, 2020 7:29 am
by Tony Li
Happy to help!