Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do my Unity Buttons need multiple taps to finally work?

As the title suggests, I have a screen with two canvases. Both literally a copy of each other, but simply having a different layout for my Portrait and Landscape orientations. As and when the orientation changes, I disable to appropriate Gameobject containing the Canvas.

enter image description here

Now, I've never had any problems with the other buttons from the previous canvas open, but I've got this problem where my active canvas needs multiple taps on the same button to finally WORK.

Should I be doing something differently?

EDIT: There's no problem when I test it on Unity Editor. Only when it goes onto an Android or iOS device.

Please keep in mind that it DOES work. It just that it takes endless tries to do so.

like image 324
Augmented Jacob Avatar asked Jun 05 '15 06:06

Augmented Jacob


1 Answers

Usually the kind of click that sometimes-works-sometimes-doesn't is caused by two colliders at the same distance from the camera.

Try changing Z-position of a button/canvas to see if this is the case.

Ray casting, which is quite likely used under the hood for canvas clicks, is only sending the onMouseDown event closest resembles colliders.

Also on the Canvas, if its on Screen Space - Camera adjust the Order in Layer so that no two canvases are on the same layer.

If there are two at the same layer, it has to choose either one of them. It seems that, in this case, unity chooses any one randomly.

like image 160
maZZZu Avatar answered Oct 13 '22 00:10

maZZZu