When I build my game to Android, buttons stop calling the onClick() function I set in the Editor. In play mode and in simulator, all works well. The only way I can make the buttons work is to make a script which adds the onclick function to the button again on startup. Is there a way to fix this without having to write a script to add it to every single button? (Buttons in other scenes dont work either)
Related
I have a main menu inside my unity game and for some reason when i build the game for android to run it on my phone the buttons does not work, but it's not disabled.
My scene objects:
My event system object:
Three things I can suggest:
First, make sure that on your button object, raycast target is deselected. At times, this is destabilizing the text of the button, hence making the button itself invalid.
Second, check to see if the EventSystem is working. From what I'm seeing on your screen, you might have disabled it or accidentally deleted its script while working on the scene objects. You can re-create it if necessary through GameObject>UI>EventSystem.
If these don't work, you can try the steps shown here:
https://answers.unity.com/questions/1115464/ispointerovergameobject-not-working-with-touch-inp.html
This is directly related to button objects not working with touch input devices. Hope this helps!
I have a custom ViewCell with bindings.
The first time I say tap on a button the bound view model command is fired. Then I refresh the ListView. I tap again on the button. The command is called twice. I refresh, I tap, now the command is called three times. Etc.
This behavior only apply on android with ListViewCachingStrategy.RecycleElement. Without it it works fine. And with it on iOS it woks fine as well.
I'm not asking for a workaround (I could either not use ListViewCachingStrategy.RecycleElement or setup all my cell elements in OnBindingContextChanged) but for a reason (if any).
Using Unity 5.0.
Working on Android.
I simply have a Canvas -> with inside a Panel -> with inside a Button.
The Button has in its 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.
But when I deploy the project on an Android (4.4.2) 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.
Seems like it is triggering a sort of "long tap" and it is ignoring my normal tap. I am missing some seetings? I have not much code at all, just the function, the rest is all done via Unity inspector.
You probably suffer from the same problem I did. Check the value for "Drag Threshold" for the "Event System (script)" which you will find in the inspector once you select the EventSystem in the hierarchy.
The default value is 5 which is tiny and anything but the briefest of touches will not register as a click but as a drag. Increase the size. I use 20 and my buttons now work as expected on Android. Which reminds me I have to check this now on iOS again as well.
Good luck
So I have tried with pure XML files and also by using the onEvent options in the Java files. Both fails to do what I want.
What I need is to add onPressed events to View objects in order to change the background depending on the state. It does work, or at least it is changing the background. However in all the applications I have seen for Android, there is some kind of delay on the Views onPressed state, so in case the user presses the screen and start scrolling, the background does not change. In my case however they always do. So I get this annoying blinking of the View objects every time I attempt to scroll.
How do I go about this to make the onPressed work correctly?
I'm using the Corona SDK and I'm still fairly new to it. I am using the Storyboard api to navigate scenes. I have a main page with a button on it. The button listener uses gotoScene to open another scene that has a tab bar. When I run the app, the button works, but the new scene is created on top of the first scene. The problem is that both scenes are being displayed simultaneously. I tried implementing destroyScene with a simple print("destroyScene called") to see if it was even being called and it wasn't. Does anyone know what I'm doing wrong? I feel like I'm missing some fundamental functionality of the storyboard api.
you can find all the answers to your questions about Storyboard API in Corona SDK by referring this sample-code
Destroy Scene is only called when you run out of memory.
You need to use exitScene to turn off the visibility of the things instead (also remove inside exitScene any event listener, so you don't trigger it by accident, and add those back on enterScene).