Show continue button ONLY at end of conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
NotVeryProfessional
Posts: 142
Joined: Mon Nov 23, 2020 6:35 am

Show continue button ONLY at end of conversation

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

Re: Show continue button ONLY at end of conversation

Post 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;
        }
    }
}
NotVeryProfessional
Posts: 142
Joined: Mon Nov 23, 2020 6:35 am

Re: Show continue button ONLY at end of conversation

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

Re: Show continue button ONLY at end of conversation

Post 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.
NotVeryProfessional
Posts: 142
Joined: Mon Nov 23, 2020 6:35 am

Re: Show continue button ONLY at end of conversation

Post 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)
NotVeryProfessional
Posts: 142
Joined: Mon Nov 23, 2020 6:35 am

Re: Show continue button ONLY at end of conversation

Post by NotVeryProfessional »

That works wonderfully. Thank you so much!
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show continue button ONLY at end of conversation

Post by Tony Li »

Happy to help!
Post Reply