Author Topic: UICamera EventReceiverMask  (Read 2312 times)

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
UICamera EventReceiverMask
« on: September 24, 2013, 01:55:10 PM »
I've entirely adopted the NguiEventSystem for my project which has been great. Thanks for that!

I'm now facing a situation on my main camera where I've got colliders from one layer covering up colliders from another, yet I need to have each able to receive events concurrently. The main camera sees both layers.

I'm wondering the best approach to take - 1) place two UICamera scripts on the main camera with the event receiver mask set to Layer A or B respectively (this works so far), 2) create a second camera slaved to the first, targeted at Layer B holding the second UICamera script, or 3) dynamically change the MainCamera's UICamera.EventReceiverMask programatically between the two. The last of course means that the two collider types can't be receiving events concurrently but I might be able to get away with this by changing the game criteria.

Which of these in your opinion, given your knowledge of the Ngui system, is the least problematic approach? Thanks for the advise.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera EventReceiverMask
« Reply #1 on: September 24, 2013, 07:05:14 PM »
Having two UICameras won't help, because only the first UICamera to process events (the last UICamera to draw) is the one that will intercept it. NGUI wasn't written with the goal of hitting multiple things -- quite the opposite. It was written to make hitting the top-most object easily, to intercept events properly. If you don't want this behaviour, just write a script to do your own a Raycast.