UI Buttons Working on Android.

Add Button script the OnClick() with a GameObject linked. The GameObject has a script with a function.

When I tap the button I simply trigger the function, which is working properly on Unity.

In Android device, it works only if you tap and leave the finger very fast. Otherwise if you tap and wait just a second, when you remove the finger the OnClick() is not called anymore.

You should use Event Triggers if you are using the latest UI, instead of the OnClick() method

  1. Add an event trigger component to the button

  2. Add a new event ( on the event trigger component) from the options select “Pointerdown” or “PointerUp”(depending on whether you want to trigger it on touch or release, respectively)

  3. Hook the corresponding function that you’d like to call, into this trigger

I found an alternate solution for this.

It’s true you must tap quickly to trigger a click but I found the most common cause for a button click not firing was drag. For me the tap timer is sufficient (probably around 300ms is standard).

This problem was specifically an issue in more complex hierarchies especially scroll views. Fortunately the issue is incredibly easy to fix.

If you change the “Drag Threshold” (pixelDragThreshold) of your EventSystem to a higher value it will fix a lot of the Android button issues. The default value is 5 but I use 44 based on Apple’s Human Interface guidelines but whatever works for you.

Also for buttons I found it important to disable raycastTarget on internal elements, say like any internal text or images.

I went along nearly implementing my own button solution for this but I found this forum post which shed light for me.

Hope that helps anyone else who comes to this!