Author Topic: How to ensure NGUI captures and filters mouse inputs?  (Read 2443 times)


  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
How to ensure NGUI captures and filters mouse inputs?
« on: December 27, 2012, 09:55:32 AM »
I've looked into the UICamera.cs code, but haven't found a simple solution to the following issue:
- I need to disable any code that uses mouse input whenever that same input has been handled by NGUI.
- example: a user clicks on an NGUI widget and drags the mouse, releasing it somewhere else on screen. When that happens, I want my camera orbiting code to skip moving the camera based on mouse displacement. That code should be skipped from the moment the user clicks to the moment he releases the mouse button.
- UICamera.hoveredobject enables me to discard anything related to Input.GetMouseButtonDown(0), just by checking that it is not null (meaning that the click happened over an NGUI widget), but that's not good enough, because hovered may become null during the drag.
- Ideally, I'd like to check a static bool 'UICamera.isInputHandledByNGUI', that would be set to true whenever a user clicks on a widget and until he releases his click.

Is there something like that available somewhere, that I might have overlooked?
I can easily have my own manager on the side that would do all the checking work for me, but it feels that it is something that should naturally belong inside UICamera.cs


  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to ensure NGUI captures and filters mouse inputs?
« Reply #1 on: December 27, 2012, 12:06:30 PM »
Don't use Input. Use NGUI's event system all the way. Instead of checking Input, rely on NGUI events -- even for your game. You will save yourself a lot of headaches.

That said, you can always check UICamera.hoveredObject to see if it's over a UI element.