Being able to click buttons multiple times - normal behaviour?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 195
Joined: Mon Jul 01, 2019 1:21 pm

Being able to click buttons multiple times - normal behaviour?

Post by lostmushroom »

Hi Tony. Is it the normal behaviour of DS to allow you to press a response button (or menu button) multiple times? I seem to remember buttons getting automatically disabled once you pressed them, but I'm able to button spam in my current game so I'm trying to figure out whether this is normal or if I've changed something.

Thanks!
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by Tony Li »

Hi,

The response buttons should be non-interactable when you click one.

When you click a response button, it calls the StandardDialogueUI's OnClick() method, which calls the current menu panel's MakeButtonsNonclickable() method, which in turn sets all instantiated buttons and design-time buttons non-interactable.

Is there something unique about the way your response buttons are configured? In general, if you leave their Button components' OnClick() UnityEvent completely empty, the response button will automatically hook up the correct action at runtime.
lostmushroom
Posts: 195
Joined: Mon Jul 01, 2019 1:21 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by lostmushroom »

I've got the response buttons working correctly (I'd been messing with OnClick methods, but it's configured correctly now).

Now it's the start/continue/restart buttons that are being weird. They're configured like this:
menu buttons.JPG
menu buttons.JPG (23.35 KiB) Viewed 405 times
The only other thing I changed was to add animations to them that make them fade in when the game starts.
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by Tony Li »

Hi,

Are they not working at all, or are they allowing multiple clicks, or something else?
lostmushroom
Posts: 195
Joined: Mon Jul 01, 2019 1:21 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by lostmushroom »

Allowing multiple clicks yeah
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by Tony Li »

Hi,

You can add a Canvas Group to the panel that contains those buttons, and edit your animation to set the Canvas Group's Interactable property false (unticked) when the animation starts, and true (ticked) when the animation ends.
lostmushroom
Posts: 195
Joined: Mon Jul 01, 2019 1:21 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by lostmushroom »

I already keyed Button.Enabled to be off until the animation is fully faded in, which seems to work okay. The problem happening after the animation plays, that's when it allows multiple clicks.

The solution I've been trying is turning off the Button.interactable using OnClick(). The problem then becomes getting it to turn back on when the game ends and returns to the main menu.

I tried animating it to switch back on (it plays the fade in animation every time it returns to main menu), but that seems to override the OnClick() and bring back the original multiple clicking problem.
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by Tony Li »

You could configure OnClick() to set Interactable false, and configure the end of the show animation (for the next time it's opened) to set Interactable true.
lostmushroom
Posts: 195
Joined: Mon Jul 01, 2019 1:21 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by lostmushroom »

Hey Tony, thanks for your help. I got this working in the end by using 2 animations - on that plays OnClick() to both fade out the button and set the interactable to Off, then another on start to fade in the button and set it back on.

For some reason, using OnClick() to actually set the button interactable to off wasn't working - it seemed to be getting overridden by the animation. I'm guessing that the animation with interactable keyed on was keeping it on all the time regardless of anything else. Just wanted to explain this in case anyone else has this same weirdly specific problem :)

Anyway it's all working now, thanks for your help as always!
User avatar
Tony Li
Posts: 22134
Joined: Thu Jul 18, 2013 1:27 pm

Re: Being able to click buttons multiple times - normal behaviour?

Post by Tony Li »

Thanks for the explanation. Glad to help!
Post Reply