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!
Related
On Xamarin Android i have set in the App.cs the MainPage property to be a NavigationPage pointing to my MainPage.xaml page, which is a ContentPage. This navigates fine.
From a Command which executes from a Button in my MainPage.xaml I await a call to Navigation.PageAsync to go to my LoginPage.xaml, also a ContentPage. This works fine.
If i choose not to Login and wish to go back to the MainPage.xaml page from some unknown reason at the point where i was close to shipping it has decided that now it takes two clicks on the Android hardware back button to make this happen. This was not the case earlier in the day, it seems as if something has gone astray with Xamarin compilation as the only change i made was add some extra colors to a ResourceDictionary. This was working fine for months.
By the way, I have checked the NavigationStack, it is correct MainPage, and LoginPage (not two LoginPage instances). I also note RemovePage does not work anymore either, the point there being that if I do Login then i Remove the LoginPage so you don't come back to it from the following page.
In trying to find a cause I overrode OnBackButton inside the Android project and sure enough, the first click does not call it, only the second does. I have no idea how to fix this, my project was nearly ready to ship, and all of a sudden this. I've tried deleting the obj and bin folders and recompiling, Debug and Release, still the same. This is the case now on both emulator and physical devices.
Might anyone have an idea where to even begin looking how to fix this or better yet have a solution?
So i finally figured it out, and it is not pretty. I was wrong about only adding colours, i had also moved from a page a Style that works on TargetType Entry into App.xaml. In theory this should NOT have made a jot of difference, it would be just be merged into all the pages ResourceDictionary as per any other resource placed at the App.xaml level. I have two pages that had the exact same Style for Entry so i consolidated them at the root.
But here is the kicker. The double back button press comes about from one setter property that is there and only when it is in the App.xaml. I had set CursorPosition to 0. This innocuous setter causes the backbutton not to fire, no exceptions are thrown, just that it has this effect. Hope this helps someone.
P.S I'd have moved to MAUI (indeed did a full port) but that has so many issues relating to Images and crashing and performance at this time it is not possible, so stuck with Xamarin for now, fying pan or fire.
I have a project that I did not develop but am trying to fix bugs in. There's a button that I press and then a bug occurs. I want to find out where in the code this button is implemented but its hard to trace it since there are so many classes and layout files. Usually, if there's text associated with the button, then I find the string in my strings.xml file and work my way back. Unfortunately, this button doesn't have any text associated with it.
Hey just connect your actual android phone and run the app on it and also open logcat, when you will click that button logcat should hopefully display all the errors and you can go to the function.
Try this and comment me back if it works
This is a unconvential method, but I used it in the beginning aswell. In Android Studio press CTRL + H to open the Find in Path dialog. This will search the whole project.
For a Button you might want to search e.g. setOnClickListener, Button etc. and navigate it down by this approach. This method will also find dynamically created Views in case it's not in the layout.xml
I have a list view with some complex layouts.
Some parts of the layouts are set visible/adjusted at runtime (i.e. not everything set by the xml).
It has caught my attention than in some "rare" cases there is a specific part (the same in all cases) that is rendered visually either a few seconds after looking at the list item or if I scroll down the list and then scoll back up again.
What I observe is that it seems like after a few seconds the list item is "redrawn" and the item suddenly appears.
I have added debug output to check for its visibility and according to the console log, the item is visible when the getView is called for that the first time.
So I have no idea what the issue might be.
How can I debug issues like this?
There is an option in the developer pane on your cellphone that flash every time a piece of screen change.
You can also use something like this https://github.com/JakeWharton/scalpel
If you are using an android device you can activate 'developer options' (you'll have to google how to do this for your device as it varies) like Luca said. These are really cool because you can see where changes appear on the screen and add layout borders etc which make it easier to see exactly what is happening. They can be really useful for debugging sometimes!
I had a similar problem and I tried removing most of my code and adding chunks back in to make sure they were working and eventually you should be able to locate at least the general area where the problem is.
Good luck! Sometimes these things can take a while!
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
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).