Author Topic: Buttons stopped working  (Read 12879 times)

BES

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Buttons stopped working
« on: April 16, 2014, 04:28:03 AM »
I made custom menu based on one of the example scenes... it was working fine until I saved it as a prefab and saved my scene..

I load the scene back up to work on it again and when I test it none of the buttons respond when the mouse is over them or if I click on them ...everything looks exactly the same(set-up wise)..so now I am confused as to why its not working..

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Buttons stopped working
« Reply #1 on: April 16, 2014, 11:04:22 AM »
Check the "Debug" option on the UICamera and you will be able to see what's eating the events.

BES

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Buttons stopped working
« Reply #2 on: April 16, 2014, 02:39:17 PM »
Check the "Debug" option on the UICamera and you will be able to see what's eating the events.

Thanks for responding, I figured it out .. for some reason the collision boxes stopped working, I deleted them and made new ones ... then the buttons responded normally again.

BES

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Buttons stopped working
« Reply #3 on: April 16, 2014, 10:26:46 PM »
Thanks for responding, I figured it out .. for some reason the collision boxes stopped working, I deleted them and made new ones ... then the buttons responded normally again.

Never mind ..still having this issue...  I build and run a dev version of my project and none of the buttons respond except the "Play Game" button..

Setting the UI camera to debug ..shows that its not even seeing any of the other buttons, its hitting the window behind them..

Its confusing since all the buttons have collisions..

adam718

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 60
    • View Profile
Re: Buttons stopped working
« Reply #4 on: April 16, 2014, 10:54:29 PM »
I upgraded NGUI from 3.5.5 to 3.5.7.
And from that time, buttons stop working, and after 10 secs, it's working.

adam718

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 60
    • View Profile
Re: Buttons stopped working
« Reply #5 on: April 16, 2014, 11:01:41 PM »
I found that it's because UICamera's IsVisible function.
I reverted changed from 3.5.7
  1.         /// <summary>
  2.         /// Helper function to check if the specified hit is visible by the panel.
  3.         /// </summary>
  4.  
  5.         static bool IsVisible (ref RaycastHit hit)
  6.         {
  7.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(hit.collider.gameObject);
  8.  
  9.                 while (panel != null)
  10.                 {
  11.                         if (!panel.IsVisible(hit.point)) return false;
  12.                         panel = panel.parentPanel;
  13.                 }
  14.                 return true;
  15.         }
  16.  
  17.         /// <summary>
  18.         /// Helper function to check if the specified hit is visible by the panel.
  19.         /// </summary>
  20.  
  21. #if UNITY_FLASH
  22.         static bool IsVisible (DepthEntry de)
  23. #else
  24.         static bool IsVisible (ref DepthEntry de)
  25. #endif
  26.         {
  27.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(de.hit.collider.gameObject);
  28.  
  29.                 while (panel != null)
  30.                 {
  31.                         if (!panel.IsVisible(de.hit.point)) return false;
  32.                         panel = panel.parentPanel;
  33.                 }
  34.                 return true;
  35.         }
  36.  

to 3.5.5
  1.         /// <summary>
  2.         /// Helper function to check if the specified hit is visible by the panel.
  3.         /// </summary>
  4.  
  5.         static bool IsVisible (ref RaycastHit hit)
  6.         {
  7.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(hit.collider.gameObject);
  8.  
  9.                 if (panel == null || panel.IsVisible(hit.point))
  10.                 {
  11.                         return true;
  12.                 }
  13.                 return false;
  14.         }
  15.  
  16.         /// <summary>
  17.         /// Helper function to check if the specified hit is visible by the panel.
  18.         /// </summary>
  19.  
  20. #if UNITY_FLASH
  21.         static bool IsVisible (DepthEntry de)
  22. #else
  23.         static bool IsVisible (ref DepthEntry de)
  24. #endif
  25.         {
  26.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(de.hit.collider.gameObject);
  27.                 return (panel == null || panel.IsVisible(de.hit.point));
  28.         }
  29.  

And it seems to be working normally.
Would you please check out what the problem is?
Thank you.

adam718

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 60
    • View Profile
Re: Buttons stopped working
« Reply #6 on: April 17, 2014, 01:33:42 AM »
After i changed the code lie above, it sometimes happens again.
That's not the way to solve the problem, i think. :'(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Buttons stopped working
« Reply #7 on: April 17, 2014, 11:14:19 AM »
The panel visibility check is needed. It's what prevents events from reaching widgets that have been clipped.

You haven't answered my last question. What is under the mouse when the events don't work?

Keep in mind that NGUI's raycasts are designed to hit widgets, sorted by depth. So although raycasts hit colliders, it's the widget depth that's used to determine what's in front. If you have a collider on a plain game object without a UIWidget on it, then NGUI will run through all the widget children and use the highest depth instead. If you want to control it, make sure that colliders are attached to widgets. (ALT+SHIFT+W to make an invisible widget).

BES

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Buttons stopped working
« Reply #8 on: April 17, 2014, 01:43:08 PM »
You haven't answered my last question. What is under the mouse when the events don't work?

I said "Setting the UI camera to debug ..shows that its not even seeing any of the other buttons, its hitting the window behind them"  to be specific..

Its says "Last hit: UIRoot(3D) - Main\Panel - Main\Window"   <-- but that doesn't make sense to me since the Panel Window collider isn't in the way of the button colliders.. to be sure I moved the window collider back by 1 ..still not hitting the buttons when I mouse over them.

Does this have something to do with me copying and pasting the buttons to make new ones after I made the first one?

I also found something odd ... clicking on the options button makes a new menu slide into view ..like the example menu..  so I tested the options menu first ...when I click on the done button it returns to the main menu like its supposed to ..but most of the buttons respond now ...but it seems to happen randomly ...so that makes things more confusing..
« Last Edit: April 17, 2014, 02:44:04 PM by BES »

BES

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Buttons stopped working
« Reply #9 on: April 17, 2014, 04:34:31 PM »
I seem to have fixed this for real this time .. don't know why this worked..

I moved the collider box for the first window to the left of the buttons ...and now the buttons respond even after saving it to a prefab and building and running a developer version of my project..

The collider box for the panel window was never directly blocking the button colliders ...so its odd to me why this worked..but I am just going to roll with it..

https://www.youtube.com/watch?v=_I9Gr2q5tIA
« Last Edit: April 17, 2014, 05:31:13 PM by BES »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Buttons stopped working
« Reply #10 on: April 18, 2014, 03:45:13 PM »
Colliders placed on game objects that don't actually have a widget don't have their own depth as a result. So they use the highest depth from the widgets underneath.