Author Topic: UICamera.fallThrough  (Read 5162 times)

jchowdown

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
UICamera.fallThrough
« on: August 19, 2013, 05:45:15 PM »
Hi, I'm following ArenMook's suggestion in this post:
http://www.tasharen.com/forum/index.php?topic=138.0
to set up a fallThrough handler in order to catch touches that don't happen in the UI.

I added a UICamera script to my main camera and set its Receiver Mask to Nothing. I then assigned
  1. UICamera.fallThrough = gameObject;
in a script (InputEventHandler.cs) that I've also attached to the main camera.

Now, in InputEventHandler.OnPress(), how do I get a reference to the actual non-ui gameobject that was pressed? I can't check UICamera.currentTouch.pressed because that value is overridden to be my fallthrough object. And I can't check UICamera.lastHit because it's null (due to mask set to Nothing).

Is the intention that I do another set of raycasts inside my OnPress handler? It seems kind of wasteful...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.fallThrough
« Reply #1 on: August 19, 2013, 09:19:46 PM »
Fallthrough object catches events that don't fall on anything else, but it still behaves as if you were over a valid object.

It's basically the equivalent of creating a large collider covering the entire screen that lies way in the back of everything.

I think in your case I'd be using a UICamera.genericEventHandler as you seem to want to know what the touch event is over. Generic event handler gets a copy of all the events, whether they were handled or not.

ransomink

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UICamera.fallThrough
« Reply #2 on: March 13, 2014, 04:13:50 AM »
I have an issue with UICamera.fallThrough. I followed the same post as mentioned above and created a script called "GameEventHandler" with the following code in the Start () function:
Sorry, it is JS, instead of C#
  1. // used for initialization
  2. function Start ()
  3. {
  4.         UICamera.fallThrough = this.gameObject;
  5. }

1. The script is attached to the main camera of the scene, not the camera inside of UI Root.
2. I added the UICamera NGUI component to the main camera and changed the Event Mask to 'Nothing'. I left the Event Type as default 'UI'.

When I tried to run the game, I get an error message stating: Assets/Scripts/ScriptEventHandler.js(22,9): BCE0005: Unknown identifier: 'UICamera'.

I have no idea why I have received this message and have been trying to figure it out. It is one of a few questions I wish to find out so I can properly utilize NGUI. It seems creating menus and HUDs are conveniently easy, but with no programming knowledge I fear making 'said' menus and HUDs work will be a challenge. Thanks in advance for any advice...

ransomink

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UICamera.fallThrough
« Reply #3 on: March 13, 2014, 05:33:27 PM »
Huzzah! I have found the answer. I had no knowledge that NGUI did not work with JavaScript/UnityScript by default so I wasn't looking for how to set it up. My apologies. However, at least we all can move on to more important matters...

For anyone else ignorant as I, check the FAQ on how to setup NGUI to work with UnityScript...