Author Topic: Issue with UICamera.fallThrough and multiple cameras  (Read 5626 times)

VapapeurTeam

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Issue with UICamera.fallThrough and multiple cameras
« on: April 18, 2013, 10:21:03 AM »
Hello,

I've got somewhat of an issue with catching events falling through my UICameras. Let me explain my setup and what I want to do (or a simplified version, at least).
1. I've got a classic UI orthographic camera which takes care of all my 2D UI. All these objects are on a layer called UI.
2. In my 3D scene, I have interactible 3D objects, which are handled by a 3D Camera, on layers A and B.

This works just fine, except there's one thing I can't figure out how to do : I want to handle interactions happening anywhere in my scene except on my 2D UI. I thought I'd use UICamera.fallThrough, but interactions happening on my 3D UI aren't "falling through", as expected. In a word, UICamera.fallThrough seems to only catch events that fell through all of the UICameras. Is there any way to catch events falling through one particular UICamera (my 2D camera in this case), no matter what happens with the other cameras ?

I thought about setting up a plane that filled up all the screen behind the 2D UI and have it catch all the events that the rest of the 2D UI wouldn't have caught. But if I do that, my 3D UI never receives any interactions anymore, even though they're on a different layer and manager by a different UICamera.

So, I got no idea how to do that. Any help ?

I hope I was clear enough, this thing is a bit messy.

Thanks in advance for your answers.
« Last Edit: April 18, 2013, 10:31:19 AM by VapapeurTeam »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Issue with UICamera.fallThrough and multiple cameras
« Reply #1 on: April 18, 2013, 05:23:46 PM »
You can't set up a fallThrough to react to only one camera. It's designed to be exactly what it suggests -- for events that fall through the cracks and don't get handled. There is also a UICamera.genericEventHandler that gets a copy of all events, but that's about it. Why are you trying to do what you're trying to do?

VapapeurTeam

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Issue with UICamera.fallThrough and multiple cameras
« Reply #2 on: April 19, 2013, 02:12:09 AM »
Well, basically, I have a 3D scene populated with buildings the player can click on. On top of that, there's a simple 2D UI with some buttons. The 2D UI is handled by an orthographic UICamera, and the clicks on 3D buildings are handled by the main camera of the scene, which has a UICamera script attached. I want to add some camera control on top of that (zoom, pan, rotation). For example, when the player right clicks and drags the mouse, it rotates the 3D camera around its vertical axis. And that's where my problem is : I want that interaction to be possible anywhere in the scene, except on the 2D UI. But if I use UICamera.fallThrough to get OnClick and OnDrag events, my camera rotation interaction won't work if the player happens to click or drag on a 3D building. Basically, I would like to catch only the events falling through the 2D UI Camera, but not the 3D one. Does it make more sense to you ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Issue with UICamera.fallThrough and multiple cameras
« Reply #3 on: April 19, 2013, 12:28:31 PM »
Right, set the UICamera.genericEventHandler and check UICamera.hoveredObject before doing your logic.

VapapeurTeam

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Issue with UICamera.fallThrough and multiple cameras
« Reply #4 on: April 22, 2013, 01:48:53 AM »
It seems to be working just fine, thanks :). In the target script of my genericEventHandler, I just check if the layer of the hoveredObject is the 2D UI layer. If that's the case, I do nothing, and it catches just what I want to catch.

Thanks again !