Author Topic: World panning ondrag + object onclick  (Read 2591 times)

rhalferty

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
World panning ondrag + object onclick
« on: November 23, 2015, 07:47:16 PM »
I am working on a game and I have two cameras. The first is the standard UI camera created for all NGUI/UI/HUD objects. The second camera is the standard "Main Camera" which displays everything else including the world. In the world I have objects that you can click on to select or activate. I have added a second UICamera script to allow me to use OnClick for these in world objects.

The problem comes when trying to add the ability to drag or touch the screen to pan around the world. I add a collider across the UI camera, so that anywhere I touch will trigger a Drag event. This then prevents the Click event from reaching the objects in the world because this collider consumes all the events. Is there a way to have this collider only capture drag events and let the Click pass through?

If not what is the better way to go about this? I would like to use NGUI for all the touch events if possible.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: World panning ondrag + object onclick
« Reply #1 on: November 25, 2015, 05:42:32 PM »
Simply subscribe to UICamera.onDragStart / onDrag / onDragEnd. Check to see if the events happen under the UI or not (UICamera.isOverUI). If not, do your camera panning.