[HOWTO] How To: Hide Quest Machine Dialogue UI Decline Button

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Hide Quest Machine Dialogue UI Decline Button

Post by Tony Li »

Normally when Quest Machine's dialogue UI offers a quest, it shows Accept and Decline buttons. This article explains how to hide the Decline button so only the Accept button is available.

If you want this to apply to all quests, add a Canvas Group to the Quest Dialogue UI's Decline Button. Set its Alpha to zero and untick Interactable. You can set the Layout Element's Preferred Width to zero to prevent it from affecting the automatic positioning of the Accept button.

If you only want to apply it to specific quests, it will require a little scripting. Here's one way:

1. First, add a specific label to the quest's Main Info > Labels section that will signify that this quest has no decline button. Let's say we add a label "NoDecline".

2. Then make a subclass of UnityUIQuestDialogueUI that overrides SetControlButtons to keep the Decline button inactive if the quest's labels contain "NoDecline":

Code: Select all

using PixelCrushers;
using PixelCrushers.QuestMachine;
public class MyDialogueUI : UnityUIQuestDialogueUI
{
    protected override void SetControlButtons(bool enableClose, bool enableBack, bool enableAcceptDecline)
    {
        base.SetControlButtons(enableClose, enableBack, enableAcceptDecline);
        if (selectedQuest.labels.Find(label => StringField.Equals(label, "NoDecline")) != null)
        {
            declineButton.gameObject.SetActive(false);
        }
    }
}
Replace the UnityUIQuestDialogueUI with your subclass in-place.
Post Reply