Page 1 of 2

cancel button doesn't cancel conversation

Posted: Fri Oct 16, 2015 11:14 am
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 2002 times

Re: cancel button doesn't cancel conversation

Posted: Fri Oct 16, 2015 11:34 am
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.

Re: cancel button doesn't cancel conversation

Posted: Fri Oct 16, 2015 11:41 am
by Arcanor
I understand. I will call StopConversation() from inside my override class. Thanks Tony!

Re: cancel button doesn't cancel conversation

Posted: Fri Oct 16, 2015 4:59 pm
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);
    }
}

Re: cancel button doesn't cancel conversation

Posted: Fri Oct 16, 2015 8:04 pm
by Tony Li
Thanks for sharing the code!

Re: cancel button doesn't cancel conversation

Posted: Sat Oct 17, 2015 10:51 am
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.

Re: cancel button doesn't cancel conversation

Posted: Sat Oct 17, 2015 10:56 am
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!

Re: my current game project

Posted: Sat Oct 17, 2015 11:13 am
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.

Re: cancel button doesn't cancel conversation

Posted: Sun Oct 18, 2015 1:44 am
by Tony Li
Awesome! Out of curiosity, are you using an inventory system from the Asset Store or your own system?

Re: cancel button doesn't cancel conversation

Posted: Sun Oct 18, 2015 3:58 am
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.