ClickEvent no longer reliable on Android device in preview15, preview16

The ClickEvent callback on elements (at least Button, VisualElement, Label) for an Android device is only firing if the tap is very quick (probably < 100ms). Any touch/press that is longer than that will not trigger the ClickEvent upon release. This behavior performed as expected in preview14 but no longer seems to be working as intended in preview15 or preview16.

Additionally, the :active state still correctly reflects that the press is still down (or up), but nothing triggers upon release.

Currently able to reproduce using:
Unity Version 2020.3.16
unity.ui@1.0.0-preview.16

1 Like

Hi,

Can you please report a bug from Unity ? Thank you.

Thanks for this tip, I have reported the bug via Unity :slight_smile:

Same Problem in iOS, Using unity 2020.3.18f1, toolkit/builder preview17 package. For me even quick taps often don’t generate cause the registercallback to fire. I just have to keep hammering the button until finally it works.

Basically broke my program since I spent 4 days resolving all the errors updating to preview17 from 14. Don’t really want to go through that again.

Bug report: Case 1365759

This seems to be the same as this bug (or at least the fix is going to be the same): Unity Issue Tracker - [UI Toolkit] ClickEvent is randomly not triggered

A fix is on the way.

In the meantime, please note that you can use Button.clicked, a general-purpose callback that will be invoked not only in the same conditions that a ClickEvent would occur, but also when any other activation of the button is being processed, for example when pressing Enter on a focused button or when using a GamePad button that creates a Submit event. To the best of my knowledge, Button.clicked works properly on Android and other mobile devices, and it’s considered good practice to use it instead of ClickEvent in the case of Buttons, since clicking is not the only way to activate a button.

Wow thanks, that is excellent information that I did not know about. I was basing my code off of the UnityRoyale UI sample.