7

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.

Augmented Jacob
  • 1,567
  • 19
  • 45
  • I get the same. Particularly with items on the edge in my case. So I guess it is just something they need to improve... – Everts Jun 05 '15 at 06:16
  • My buttons are in the center. So it's for buttons in general. But for me it's just not a double tap or triple tap. I have to tap endlessly till it finally registers. So there's got to be something wrong! – Augmented Jacob Jun 05 '15 at 06:18
  • You could try changing the Z-pos of one of the buttons. It sounds like you have two or more colliders at the same distance from the camera. In that case the click might be send randomly to one or the other gameObject. – maZZZu Jun 05 '15 at 12:03
  • @maZZZu Both my canvas/buttons don't have colliders. Do Graph RayCasters count for the same? – Augmented Jacob Jun 07 '15 at 04:55
  • Usually raycasting is detecting intersection with colliders. So quite likely, Unity is using them under the hood with canvas to detect what was clicked. No matter what we call them, your problem sound just like what happens when there are two things at the same distance from camera. – maZZZu Jun 07 '15 at 05:22
  • @maZZZu but when one Canvas is made unactive using `SetActive(false)` shouldn't that cover it? Anyway, I will give it a try and get back to you. – Augmented Jacob Jun 07 '15 at 13:10
  • @maZZZu Well, it worked. If you want to go ahead and type it down as an answer, I shall mark it accordingly. :) Thanks! – Augmented Jacob Jun 09 '15 at 01:59
  • Great, that my experience based guess was helpful! I tried to wrote everything into an answer. – maZZZu Jun 09 '15 at 05:23

2 Answers2

2

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.

Augmented Jacob
  • 1,567
  • 19
  • 45
maZZZu
  • 3,585
  • 2
  • 17
  • 21
0

I had the same problem. In my case, the reason was that I had both: TouchInputModule and StandaloneInputModule on the same gameObject. Just removing one of inputs solves my problem.

Edwin
  • 1