cancel button doesn't cancel conversation

Announcements, support questions, and discussion for the Dialogue System.
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

cancel button doesn't cancel conversation

Post by Arcanor »

I've noticed that when I click the cancel button (in my case, the Escape key) during a conversation, it acts the same as the Continue button (which I have set to "Always"). The conversation doesn't get interrupted until there's a choice of responses. Once the conversation hits a node that has more than just the continue button, the conversation does end as expected.

Am I doing something wrong in my setup perhaps? I've attached a screenshot of my dialogue system controller settings.
dialogue system settings 2015-10-16_11-12-07.jpg
dialogue system settings 2015-10-16_11-12-07.jpg (88.83 KiB) Viewed 2004 times
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: cancel button doesn't cancel conversation

Post by Tony Li »

Hi Walt,

That's how it's designed.

When a conversation is showing a subtitle, it listens for the Cancel button. If the player presses Cancel, it ends the subtitle. Then it progresses to the next stage in the conversation.

When a conversation is showing a response menu, it listens for the Cancel Conversation button. If the player presses Cancel Conversation, it ends the entire conversation.

If you want to end the entire conversation when showing a subtitle, call DialogueManager.StopConversation(). If you're subclassing UnityUIDialogueUI, you could start a coroutine in ShowSubtitle() that listens for Cancel, and stop the coroutine in HideSubtitle(). Or, even simpler, just add a script that calls DialogueManager.StopConversation() whenever the player presses the Cancel button. If you call DialogueManager.StopConversation() when no conversation is active, it just ignores it.
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

Re: cancel button doesn't cancel conversation

Post by Arcanor »

I understand. I will call StopConversation() from inside my override class. Thanks Tony!
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

Re: cancel button doesn't cancel conversation

Post by Arcanor »

I've got it working, thanks for your advice.

Here's the code I used, if anyone else is interested:
NOTE: EDITED for code bug on Oct 23, 2015! Changed [if (cancelKey == null)] to [if (cancelKey == KeyCode.None)].

Code: Select all

using UnityEngine;
using System;
using System.Collections;
using PixelCrushers.DialogueSystem;

public class CustomUguiDialogueUI : UnityUIDialogueUI
{
    public override void ShowSubtitle(Subtitle subtitle)
    {
        // Add your code here to show a subtitle. Subtitles contain information such as the player 
        // type (PC or NPC), portrait texture, and the formatted text of the line.
        StartCoroutine("SubtitleDetectCancelKey");
        base.ShowSubtitle(subtitle);
    }

    public IEnumerator SubtitleDetectCancelKey()
    {
        var cancelKey = DialogueManager.Instance.displaySettings.inputSettings.cancel.key;
        if (cancelKey == KeyCode.None)
        {
            yield break;
        }

        while (!Input.GetKeyDown(cancelKey))
        {
            yield return null;
        }

        DialogueManager.Instance.StopConversation();
    }

    public override void HideSubtitle(Subtitle subtitle)
    {
        // Add your code here to hide a subtitle.
        CancelInvoke("SubtitleDetectCancelKey");
        base.HideSubtitle(subtitle);
    }
}
Last edited by Arcanor on Fri Oct 23, 2015 6:53 am, edited 2 times in total.
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: cancel button doesn't cancel conversation

Post by Tony Li »

Thanks for sharing the code!
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

Re: cancel button doesn't cancel conversation

Post by Arcanor »

Thanks for sharing YOUR code Tony! As well as all the time you put in every day in making Dialogue System better and better. For the pittance that I've paid you, I feel like I still owe you quite a bit more in exchange for the value you've given to my projects.
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: cancel button doesn't cancel conversation

Post by Tony Li »

My pleasure! Feel free to throw me a link to your game site and/or some screenshots or video to put up on the Games Showcase page!
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

Re: my current game project

Post by Arcanor »

Thanks for your interest! My current project is called "Arcanoria Chronicles – Chapter 1: Early Adventures of Elora Smyth" (http://arcanoria.com/games/game-develop ... hronicles/). It's the first project that I've used Dialogue System with. I'll let you know when I've got a decent promo video, and I'll try to make sure to get some nice shots showing my implementation of Dialogue System. :) I'm hoping to release an Alpha by the end of October.
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
User avatar
Tony Li
Posts: 21676
Joined: Thu Jul 18, 2013 1:27 pm

Re: cancel button doesn't cancel conversation

Post by Tony Li »

Awesome! Out of curiosity, are you using an inventory system from the Asset Store or your own system?
Arcanor
Posts: 81
Joined: Sun Oct 05, 2014 4:20 am

Re: cancel button doesn't cancel conversation

Post by Arcanor »

I'm currently trying to decide just how important targeting the web player is to me. If I decide not to support the web player, I can use SQLite, and will create my own system. But I'd be interested to know if you had a recommendation of something that you know works well with Dialogue System.
Arcanoria Games - http://www.arcanoria.com - indie game development blog
twitter: https://twitter.com/WaltCollins3 @WaltCollins3
Game titles: Pesticide Patrol, Arcanoria Chronicles, CyberGhost, Arcanoria
PLAY NOW: http://arcanor.itch.io/
Post Reply