Author Topic: Callback when user does not click on a GUI element?  (Read 2468 times)

miivers

  • Guest
Callback when user does not click on a GUI element?
« on: July 27, 2013, 06:17:20 PM »
Hello

I would like a callback when the user does a mouse click but outside my GUI. It was suggested to assign "UICamera.fallThrough" to a gameobject for handling unprocessed events in another post.

I have two classes that handles user input:
GuiInput
UnprocessedInput

When I assign UICamera.fallThrough to UnprocessedInput and I click on the terrain(which is not an gui element) in my game will result on GuiInput.OnClick() will be called before UnprocessedInput.OnClick(). Am I missing something to get this working?

To shorten my question. I only want UnprocessedInput to recieve OnClick() callbacks when I click on my terrain. Currently GuiInput gets called before UnprocessedInput.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Callback when user does not click on a GUI element?
« Reply #1 on: July 28, 2013, 08:41:45 AM »
What's GUIInput?

FallThrough receives events that don't get handled by the GUI. It's exactly for the reason you're describing -- to handle events that go outside the GUI -- such as clicking on the terrain.

miivers

  • Guest
Re: Callback when user does not click on a GUI element?
« Reply #2 on: July 28, 2013, 04:07:04 PM »
Oh my.

Must have been a late night last night. I do not fully understand what I was doing but the two classes GuiInput and UnprocessedInput I made was suppose to do some input logic. They was even calling each others OnClick function resulting in a strange debug output on the console. I thought I had misunderstood how NGUI works.

Works fine now after cleaning out some code...