Author Topic: Detect touch outside of panel when panel is open  (Read 2400 times)

singh029

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 28
    • View Profile
Detect touch outside of panel when panel is open
« on: December 14, 2015, 11:46:07 PM »
is there an ngui way to detect when user touches outside of the panel when the panel is open.

an open panel is visible on the screen. a closed panel slides off of the screen.

I was trying to use this method

http://answers.unity3d.com/questions/947856/how-to-detect-click-outside-ui-panel.html

but ngui panel and rect transform dont play well together.

Currently i just have a box collider that slides in with the panel.
There has to be a better method!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Detect touch outside of panel when panel is open
« Reply #1 on: December 15, 2015, 10:16:56 AM »
Panel, in NGUI's terms, is just a script that draws widgets. Panel has no "rect".

Now if you create an invisible widget (ALT+SHIFT+W), then it will have a rect and you can place a collider on it (ALT+SHIFT+C), thus allowing it to receive touch events.

If you want to check if your touch is within the UI, easiest thing to do is to check UICamera.isOverUI -- this will work with NGUI's events, such as OnDrag, OnHover, OnClick, etc.