Author Topic: UIButton not firing on mouse 40% of the time  (Read 2237 times)

Euthyphro

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
UIButton not firing on mouse 40% of the time
« on: September 08, 2015, 01:01:49 AM »
Problem:
Pretty simple question, could someone tell me why this button in the image below doesn't fire when two identical buttons do fire on mouse collision? It does work 60% of the time, but 40% of mouse hovers dont fire off and the user has to wiggle and juggle the mouse a few times over it for the button to detect mouse intersect with button collider. Any suggestions on why this might be happening? Yes collider is on, yes collider is the same size as the button, no there is no spike in the profiler that would stutter, the scene remains at 59FPS - those were the first things to check - the problem still persists.

Set up:
UI set up as 3D UI. Using the Control - Simple Button prefab that comes with NGUI and absolutely no modifications to the button at all. The Control - Button is the child of a UI Panel and the UI Panel is child to UI Root.

The only thing I can think of was that I copy/pasted the button within the editor but I'm hesitant to call that the problem as I cant reproduce this as the point of this problem.

Edit: I would like a point of clarification. For UIPanels that I'm not using and I want to hide, I am calling uiPanel.enabled = false; Is this incorrect? I'm noticing that the panel is still active but renderer disabled. Nonetheless, I can see for panels that are stacking it is causing issues with button clicks. What is the proper way to hide a UIPanel not being used? What is the point of having UIPanel.enabled = false if it causes issues with overlays?


UI Button:


UI Panel (Parent of button):


UI Root:


UI Camera:
« Last Edit: September 08, 2015, 01:23:40 AM by Euthyphro »

Ony

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UIButton not firing on mouse 40% of the time
« Reply #1 on: September 09, 2015, 05:09:32 PM »
I'm having this same exact problem. My buttons have been working perfectly for months in Unity 4x Pro, and I recently converted the project to Unity 5 (currently using 5.1.1f1).

Now my buttons are exhibiting this behavior. Sometimes clicking, sometimes not. When they don't click, you have to move the mouse off of the button then back on again to get it clickable. Then I can click several times in a row and then boom, back to unclickable.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton not firing on mouse 40% of the time
« Reply #2 on: September 13, 2015, 05:17:28 AM »
@Euthyphro: Don't disable the panel like that. Either disable the entire game object, or set the panel's alpha to 0. Disabling the panel will have adverse effects when widgets try to find their owner.

@Ony: When you turn on debugging on the UICamera, does it show the mouse hovering over the correct collider?

Ony

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UIButton not firing on mouse 40% of the time
« Reply #3 on: October 13, 2015, 12:46:53 AM »
@Ony: When you turn on debugging on the UICamera, does it show the mouse hovering over the correct collider?
It does. I would think it was my code but nothing changed in my code between changing from Unity 4.x to Unity 5.x aside from the few API updates it made.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton not firing on mouse 40% of the time
« Reply #4 on: October 13, 2015, 01:17:28 AM »
What type of colliders are you using?