Author Topic: Block input to main camera?  (Read 7567 times)

Chris_E

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 37
    • View Profile
Block input to main camera?
« on: May 05, 2012, 07:26:32 PM »
I have a volume slider on my nGUI camera, and a script that rotates an object when I click and drag across it.  I know I found the answer to this problem somewhere, but I can't find it now.

How do I make it so if I click the slider the input is ignored by the rotating object?

Thanks!

Chris

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Block input to main camera?
« Reply #1 on: May 05, 2012, 07:42:28 PM »
Unless you've done something custom (such as handling Input yourself), NGUI will not let events go through the slider, assuming it's on top of your other widget.

Chris_E

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 37
    • View Profile
Re: Block input to main camera?
« Reply #2 on: May 05, 2012, 07:48:06 PM »
I guess I worded it wrong, it's not exactly going through.  It's going to a different camera, the main camera.

The rotating object is on the main camera (which received nGUI events, in case that matters.)

Thanks again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Block input to main camera?
« Reply #3 on: May 05, 2012, 07:50:01 PM »
The highest depth camera receives events first. If a collider there intercepts the event, it's not sent to a lower depth camera. If you don't want a certain camera to receive events, disable them on your UICamera.

Chris_E

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 37
    • View Profile
Re: Block input to main camera?
« Reply #4 on: May 13, 2012, 11:09:46 PM »
I figured out the problem!

I'm not testing for a click, I'm testing for OnMouseDown.

I guess what I need is a way to ignore OnMouseDown if it's on an element on the nGUI camera.

Is this possible?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Block input to main camera?
« Reply #5 on: May 14, 2012, 12:06:04 AM »
You'll need to check what's under the UICamera.hoveredObject... but I suggest just using NGUI's events rather than hacking this in like that.