Skip dialogue choices outside of dialogue

Announcements, support questions, and discussion for the Dialogue System.
boz
Posts: 76
Joined: Mon Oct 19, 2020 8:59 pm

Re: Skip dialogue choices outside of dialogue

Post by boz »

It took me awhile to figure out and remember how the original code worked, but eventually got it. Thank you for the advice!

Code: Select all

    private Response[] regularResponses;

    protected override void SetResponseButtons(Response[] responses, Transform target)
    {
        regularResponses = responses;
        foreach (Response response in responses)
        {
            response.enabled = false;
        }

        base.SetResponseButtons(regularResponses.ToArray(), target);
    }

    public void SelectCard(int index)
    {
        (DialogueManager.dialogueUI as StandardDialogueUI).OnClick(regularResponses[index]);
    }
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip dialogue choices outside of dialogue

Post by Tony Li »

Happy to help! I'm glad you got it working.
boz
Posts: 76
Joined: Mon Oct 19, 2020 8:59 pm

Re: Skip dialogue choices outside of dialogue

Post by boz »

Okay, I started getting more complex with it and now I've hit a situation where I don't know how to customize the Response Button any further.

Essentially, when I'm setting up the button, I also want to store a reference to a script that controls other elements on the button (see the image for example). Like while I do things in the game, I want to update the number on the response button.

The problem I'm hitting is that there's no reference to the GameObject inside of SetResponseButtons(), so I don't know how to access the button template itself to get the reference.

Any advice? It can be something dirty for now because I'm prototyping. I've been hesitant to crack open the Response script and add a direct reference to what I want inside there, but if you think that's the way to go, then I'll do that.
Attachments
2022-10-05 23_52_09-Twilight Tower - Figma.png
2022-10-05 23_52_09-Twilight Tower - Figma.png (11.71 KiB) Viewed 345 times
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip dialogue choices outside of dialogue

Post by Tony Li »

Hi,

Make a subclass of StandardUIResponseButton with UI element(s)s for the [#/#] text. Use this on your response buttons instead of the original StandardUIResponseButton.

Then override StandardUIMenuPanel.SetResponseButton(), which is the method that sets up a single response button, to set those extra UI element(s).
boz
Posts: 76
Joined: Mon Oct 19, 2020 8:59 pm

Re: Skip dialogue choices outside of dialogue

Post by boz »

Aha! That set me on the right track. I had another component trying to do something close to the same thing, but didn't think to make it inherit from StandardUIResponseButton instead. Thanks!

Code: Select all

    protected override void SetResponseButton(StandardUIResponseButton button, Response response, 
        Transform target, int buttonNumber)
    {
        if (button is CardVoteResponseButton cardVoteResponseButton)
        {
            _responseButtons[buttonNumber] = cardVoteResponseButton;
            _responseButtons[buttonNumber].currentIndex = buttonNumber;
        }

        base.SetResponseButton(button, response, target, buttonNumber);
    }
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip dialogue choices outside of dialogue

Post by Tony Li »

Looks good!
Post Reply