- Home /
Weird Unity buttons.Sometime works, sometime doesn't work.
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.
button works sometime & sometime it doesn't work
Button or buttons? Do some work and some don't? Or sometimes all buttons either work or don't?
they don't listen to my code. they will give output sometime & sometime will not give output. All of the BUTTONS behaves like this.
What do the buttons do? And what are the outputs from your debug log?
Do the buttons respond to a mouse click. I had something not totally different when I first started the new 4.6 UI. What I'd done is enabled a panel over the top of some buttons. Hadn't noticed I'd bumped the transform so it was now over the button.
Anyway give us some more details or even screen shots.
Check if your buttons are covered by some other Collider. $$anonymous$$ight be that there is another object with collider on the same Z-axis value that gets in front of your buttons. Really, I have not enough information to help you with this.
I experienced a similar issue once. I had a panel partially covering a button, so it wouldn't work when I clicked on it. The reason it took so long for me to figure out was because the part of the panel that was covering my button was invisible. Being invisible doesn't mean it's not there though. I couldn't click through it so it was like I wasn't clicking on the button at all.
Answer by Mmmpies · Dec 20, 2014 at 07:50 PM
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.
Answer by Egil-Sandfeld · Feb 02, 2016 at 05:31 PM
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 ;)
Thanks so much! I have another canvas for game pause/timeline buttons that needed to be independent of other UI objects
Answer by rsodre · Feb 26, 2016 at 08:19 PM
Is it inside a ScrollRect hierarchy? Try adding an empty EventTrigger to the button.
Answer by EdwinFoe · May 26, 2016 at 09:44 PM
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.
Answer by moment_um · Jan 04, 2016 at 02:43 PM
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.
Your answer
Follow this Question
Related Questions
[C#] How to code within the Unity 4.6 new UI Panels? 0 Answers
unity 4.6 ui canvas panel solid color 1 Answer
Splitting the game view - part camera, part opaque navigational panel at runtime 1 Answer
Buttons around game object. UGUI 4.6 0 Answers
Animate a panel to be outside canvas no matter size? 1 Answer