Being able to click buttons multiple times - normal behaviour?
-
- Posts: 192
- Joined: Mon Jul 01, 2019 1:21 pm
Being able to click buttons multiple times - normal behaviour?
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!
Thanks!
Re: Being able to click buttons multiple times - normal behaviour?
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.
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.
-
- Posts: 192
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Being able to click buttons multiple times - normal behaviour?
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: The only other thing I changed was to add animations to them that make them fade in when the game starts.
Now it's the start/continue/restart buttons that are being weird. They're configured like this: 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?
Hi,
Are they not working at all, or are they allowing multiple clicks, or something else?
Are they not working at all, or are they allowing multiple clicks, or something else?
-
- Posts: 192
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Being able to click buttons multiple times - normal behaviour?
Allowing multiple clicks yeah
Re: Being able to click buttons multiple times - normal behaviour?
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.
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.
-
- Posts: 192
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Being able to click buttons multiple times - normal behaviour?
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.
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?
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.
-
- Posts: 192
- Joined: Mon Jul 01, 2019 1:21 pm
Re: Being able to click buttons multiple times - normal behaviour?
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!
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?
Thanks for the explanation. Glad to help!