Page 1 of 1

Being able to click buttons multiple times - normal behaviour?

Posted: Thu Feb 23, 2023 5:28 pm
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!

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

Posted: Thu Feb 23, 2023 6:40 pm
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.

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

Posted: Wed Mar 01, 2023 4:09 pm
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 366 times
The only other thing I changed was to add animations to them that make them fade in when the game starts.

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

Posted: Wed Mar 01, 2023 5:05 pm
by Tony Li
Hi,

Are they not working at all, or are they allowing multiple clicks, or something else?

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

Posted: Wed Mar 01, 2023 5:14 pm
by lostmushroom
Allowing multiple clicks yeah

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

Posted: Wed Mar 01, 2023 5:24 pm
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.

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

Posted: Wed Mar 01, 2023 5:58 pm
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.

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

Posted: Wed Mar 01, 2023 7:12 pm
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.

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

Posted: Thu Mar 02, 2023 9:47 am
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!

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

Posted: Thu Mar 02, 2023 10:14 am
by Tony Li
Thanks for the explanation. Glad to help!