Hello everyone,

I am facing the weirdest thing of Unity.
In Unity 4.6.1, i have implemented a canvas. In canvas there is one panel, and that one panel have 9 children panels. Each panel of these 9 panels, contains one button.
I have applied functions on all of those buttons.Function script is applied on parent game object of these 9 panels. So, script is applied on a panel.
When i play the game, button works sometime & sometime it doesn’t work.

I have just put Debug statement on all buttons.
Please help me & let me know, if any one facing the same problem.

I was facing same problem in Unity 4.6.0 also.
Thanks.

My issue was solved because I had two Canvas displaying at the same time. I fixed my issue by assigning “Order in Layer” in one of the canvas’ to 1. They were both 0 previously, which probably caused some issues :wink:

OK the answer looks like a panel was over some of the buttons as I posted that first I’m putting this in as the answer.

Good idea to make buttons really obvious when being clicked during debugging issues then you can what is reacting to a click.

The panels are transparent as @RedHedZed points out so difficult to spot another debug idea is to look in the scene view whilst the game is running to see what panel is where.

It helps others if the answer is ticked correct, because who checks unanswered questions for a fix for their similar problem, so feel free to approve the answer or any of the comments.

Is it inside a ScrollRect hierarchy?
Try adding an empty EventTrigger to the button.

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.

i’m having the same issue. it cant be layers or anything, BC 1.) I can press play, do nothing but press the button and it works, and then stop and play again, press the button and it doesn’t work. I think it as something to do with that stupid frustum out of view bug. 2.) I have attempted putting everything on different layers, zed’s and sorting layers… still doesn’t work. I don’t understand how something can work sometimes and not others.

Click on EventSystem in Hierarchy and set “Force Module Active” to true.

The solution I found to this was that in the 2DTransform mode the Blue 2D Rectangle Box must encase the whole Object because that is being used as the Raycast target zone. If you have it only encasing half the object then no wonder it sometimes works. Once i scaled it to encompass my whole text object it worked flawlessly.

I had this seemingly same problem and it was caused by a transparent portion of an image overlaying the button so it wasn’t immediately obvious. drawing the button after the image solved the problem.

Just dont use 2 ui at same time. Make one deactive when other is open.

I was Having the same issue. In my case, the button was placed as a child of a panel. There were two buttons as the child of that panel and both of them were sometimes working, other times not. Mistake: I had attached a slider Element to the panel as a component of the panel and not as its child. Just when I removed it, everything started working fine!

Maybe in your case, there are UI elements or some other elements attached as the components which might be causing the problem.

I’ve accidentally put rigidbody2D component to canvas and it caused the same issue.

I’ve solved this issue a few times by searching my objects by type, and making sure no images or text are raycast targets that shouldn’t be.