UI button events not working on android
After testing UI buttons int the editor and making sure they're working fine, I went ahead and deployed an APK package to my Android phone. While the buttons show the clicking animation, the functionality is simply not there. I did multiple tests and tried different solutions posted online and nothing worked for me. Here is a snapshot of my EventSystem. I tried enabling the "Force Module Active" for both Standalone and Touch input modules in all the different combinations but not avail.
And here is a snapshot of one of my Button GameObjects. I tried disabling the "Graphics Raycaster" script on the parent GameObject containing the Canvas component. I tried changing the way the function that is called through the EventTrigger attached to buttons works. The function that is called through the EventTrigger calls a function on another object if that helps. (Note: ButtonEventHandler is my script and not to be confused with Unity's Standard Assets' "ButtonHandler" script. It contains two methods that I have written with the names OnPointerDown and OnPointerUp)
It is as if the functions are not being called when the buttons get tapped on the phone. They work perfectly when clicked with a mouse in the Unity Editor.
Hi there, did you manage to work this out? I have switched to android build and my mac sometimes gets events, sometimes doesn't...I cannot figure it out if its a bug or not.
Answer by hellaeon · Jul 04, 2016 at 11:04 PM
Ignore my comment, I just realised you need to attach a standalone input module to the canvas
Answer by pedrampk · Jul 13, 2018 at 02:19 PM
in a project, my UI buttons worked in Editor but not worked in Android device. my problem was solved after searching on "problems with IsPointerOverGameObject()" function. the bellow page helped me to solve this problem. I hope it is usefull for you.
https://answers.unity.com/questions/1115464/ispointerovergameobject-not-working-with-touch-inp.html
it seems that you should use IsPointerOverUIObject() user defined function.
Answer by ajitrko7 · Nov 27, 2020 at 01:59 AM
Hello, I am working on a android project..thirdperson game..I use fixed joystick for movement and Ui buttons for other functions..everything is work fine in editor..but after build for mobile..joystick works fine..but when I press ui button..the screen gets entirely dark..I tried many ways...help me to sort out this.Thanks in advance.
Your answer
Follow this Question
Related Questions
How to get access to bool from one script to another with touch input? 1 Answer
What is the best way to implement a more responsive custom drag event with Scroll Rect? 0 Answers
How can I make a UI button press affect something in a text box? 0 Answers
How to make button click continuous ? 0 Answers
With the new unity input system. How do I setup UI buttons like in the old system. 0 Answers