[Solved!] How to Manipulate Response Buttons

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
CodePrincess
Posts: 111
Joined: Thu Sep 27, 2018 11:06 pm

[Solved!] How to Manipulate Response Buttons

Post by CodePrincess »

Hi, Mr. Li!

I figured out that if you add a checkmark image to the Response button template, every button created gets it's own check mark. Is there a way to single out an individual response button in runtime and change its checkmark's active state?

Thank you very much for your help!
Last edited by CodePrincess on Wed Sep 04, 2019 9:28 pm, edited 1 time in total.
Thank you so much for your help.

Oh! My stats!
Unity 2020.1.10f1
Adventure Creator 1.72.2
Dialogue System for Unity 2.2.12
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Manipulate Response Buttons

Post by Tony Li »

Hi,

You can make a subclass of StandardDialogueUI and override the ShowResponses method as in this example:

Code: Select all

public class MyDialogueUI : StandardDialogueUI
{
    public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
    {
        // Set up the response buttons like 
        base.ShowResponses(subtitle, responses, timeout);
        
        // Activate the first button's checkmark image:
        var firstButton = conversationUIElements.defaultMenuPanel.instantiatedButtons[0];
        firstButton.Find("Checkmark").SetActive(true);
    }
}
Or you may find it simpler to add a script to the Dialogue Manager that has an OnConversationResponseMenu method:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
    StartCoroutine(DoSomethingAtEndOfFrame()); // Give dialogue UI until end of frame to set up menu buttons.
}

IEnumerator DoSomethingAtEndOfFrame()
{
    // Activate the first button's checkmark image:
    var dialogueUI = DialogueManager.dialogueUI as StandardDialogueUI;
    var firstButton = dialogueUI.conversationUIElements.defaultMenuPanel.instantiatedButtons[0];
    firstButton.Find("Checkmark").SetActive(true);
}
CodePrincess
Posts: 111
Joined: Thu Sep 27, 2018 11:06 pm

Re: How to Manipulate Response Buttons

Post by CodePrincess »

Wow, you are so fast! :-D Thank you!
Thank you so much for your help.

Oh! My stats!
Unity 2020.1.10f1
Adventure Creator 1.72.2
Dialogue System for Unity 2.2.12
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Manipulate Response Buttons

Post by Tony Li »

Happy to help! :-)
Post Reply