Author Topic: UICamera OnPress hit on Parent Object  (Read 1410 times)

cdcmacdaddy

  • Guest
UICamera OnPress hit on Parent Object
« on: November 23, 2013, 10:49:55 PM »
Hi - I'm new to NGUI and am enjoying it so far. I ran into something though and didn't know the solution.

My mainCamera has the UICamera script on it,
and I have an environment that is something like this:

Environment_Root
     Terrain
     TerrainObject
          TerrainObject_Example
          TerrainObject
     TerrainObject
     TerrainObject
     TerrainObject
…and so on.

If I put an OnPressed() script on Environment_Root, it doesn't receive presses. If I put it on TerrainObject_Example, then that one object gets presses. I'm looking for a way to receive a notification whenever the player taps on the environment, and handle the tap accordingly.

Is it necessary to put an OnPress() script on every piece of environment geometry with a collider? Or is there a way to have the Environment_Root object get the OnPressed() call for every press on a child object?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera OnPress hit on Parent Object
« Reply #1 on: November 24, 2013, 01:50:59 AM »
You can set UICamera.genericEventHandler, and that object will receive a copy of all your events. You can also set UICamera.fallThrough, and that object will receive all events that "fall through" others. So if you removed the main camera's UICamera and set the 'fallThrough' to your "generic event manager" or something like that, that object would get your events that don't affect the UI.

Otherwise, yes -- you need to have OnPress() listeners on everything you want to receive OnPress. NGUI events don't bubble up (yet).