Author Topic: Input on Clipped Content  (Read 2408 times)

kromenak

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Input on Clipped Content
« on: January 13, 2014, 02:08:25 PM »
Perhaps this is by design in the NGUI 3.0, but I wanted to check.  I noticed that when we have a scrolling panel that is clipped, I can still click buttons on the scrolling panel that are outside the clipping area.  This has lead to some confusion and bug reports, since testers tap on an empty area underneath a clipped panel, but it still reacts as though you've just clicked a button that is outside the clipping area.

It's possible to add additional colliders to block input outside of the clipped panel, but that seems like a hack that wasn't required with previous versions of NGUI.  I also noticed that this seems to only happen when the UICamera Event Type is set to "World".  Setting it to "UI" seems to behave correctly, but I haven't tested it thoroughly.

So, should input function this way, or is this a bug?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Input on Clipped Content
« Reply #1 on: January 13, 2014, 05:33:20 PM »
You need to set your UICamera to "UI" mode, not "World". "World" is meant for world events. UI is meant for UI events. Only UI events can be clipped by UI hierarchy (panels).

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Input on Clipped Content
« Reply #2 on: April 07, 2014, 04:00:44 AM »
I'm currently running v3.5.6 and got this issue, even with mode set to "UI". Any hints of what I might be doing wrong?

Edit:
Can it be a bug related to nested panels?
« Last Edit: April 07, 2014, 04:14:29 AM by helmesjo »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Input on Clipped Content
« Reply #3 on: April 08, 2014, 12:55:39 AM »
Most likely, yes. Change UICamera.IsVisible to this:
  1.         static bool IsVisible (ref RaycastHit hit)
  2.         {
  3.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(hit.collider.gameObject);
  4.  
  5.                 while (panel != null)
  6.                 {
  7.                         if (!panel.IsVisible(hit.point)) return false;
  8.                         panel = panel.parentPanel;
  9.                 }
  10.                 return true;
  11.         }

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: Input on Clipped Content
« Reply #4 on: April 08, 2014, 05:07:31 AM »
Most likely, yes. Change UICamera.IsVisible to this:
  1.         static bool IsVisible (ref RaycastHit hit)
  2.         {
  3.                 UIPanel panel = NGUITools.FindInParents<UIPanel>(hit.collider.gameObject);
  4.  
  5.                 while (panel != null)
  6.                 {
  7.                         if (!panel.IsVisible(hit.point)) return false;
  8.                         panel = panel.parentPanel;
  9.                 }
  10.                 return true;
  11.         }

Had to make the same change for static bool IsVisible (ref DepthEntry de) also, but now it works (guess you meant this too). Don't forget til next update!

Thanks! :)
« Last Edit: April 08, 2014, 06:29:45 AM by helmesjo »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Input on Clipped Content
« Reply #5 on: April 09, 2014, 03:57:42 AM »
Will do, thanks!