Author Topic: Block clicks from objects in another camera  (Read 3132 times)

fanling3

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 29
    • View Profile
Block clicks from objects in another camera
« on: July 27, 2015, 11:34:00 PM »
I have 2 cameras (A and B, only A contains uiCamera) and are looking at different objects (A and B) respectively, in different layers. I have collider and OnPress functions on object A.

What I want to do is when object B overlaps object A on the screen (but they are actually in different positions in world space), OnPress will not trigger. However the current situation is the OnPress function triggers because camera A cannot see object B (they are in different layers). Even I include all event masks on camera A, still does not work.

Any solution other than cloning an invisible collider in camera A and keep updating its position with object B. Thank you.
« Last Edit: July 28, 2015, 04:25:48 AM by fanling3 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Block clicks from objects in another camera
« Reply #1 on: July 28, 2015, 06:33:40 PM »
Put UICamera on both cameras, and ensure the object has a collider. Last camera to draw will handle raycasting into it, and if something is hit, earlier cameras won't get the event.