Cancel dialogue anytime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fr4231
Posts: 20
Joined: Sun Nov 28, 2021 9:44 am

Cancel dialogue anytime

Post by fr4231 »

Hello,

Having a bit of an issue with cancelling dialogues.
It’s set to ESC and it seems to be actually working fine but only if the conversation is at a line by the Player. Press ESC and the dialogue closes as expected.
However doing the exact same thing while an NPC is talking nothing happens, the dialogue just jumps to the next line without closing the dialogue.
Is it the expected behavior or am I doing something wrong?
How should I set things up so by pressing ESC regardless of the actor the dialogue could closed?
Thank you.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cancel dialogue anytime

Post by Tony Li »

That's the default behavior.
  • If the conversation is showing a subtitle (e.g,. NPC line), it listens for the Cancel Subtitle Input. If the player presses the Cancel Subtitle Input, it cancels the subtitle.
  • If the conversation is showing a response menu, it listens for the Cancel Conversation Input. If the player pressed the Cancel Conversation Input, it cancels the entire conversation.
If you want to do something different, disable both of these inputs by setting their Key values to None. Then add a script like this to the Dialogue Manager:

Code: Select all

using UnityEngine;
using PixelCrushers;
using PixelCrushers.DialogueSystem;
public class CancelConversationOnEsc : MonoBehaviour
{
    void Update()
    {
        if (DialogueManager.isConversationActive && InputDeviceManager.IsKeyDown(KeyCode.Escape))
        {
            DialogueManager.StopAllConversations();
        }
    }
}
fr4231
Posts: 20
Joined: Sun Nov 28, 2021 9:44 am

Re: Cancel dialogue anytime

Post by fr4231 »

worked nicely, thank you!
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cancel dialogue anytime

Post by Tony Li »

Glad to help!
Post Reply