Author Topic: ClickThrough  (Read 3587 times)

williamian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
ClickThrough
« on: January 05, 2015, 11:35:00 AM »
How can I simply set the UI to only register clicks and other mouse events only on the UI and ignore everything else in scene, good god, there has to be a simple built in function for that does not require scripting, HELP.

Thank you.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: ClickThrough
« Reply #1 on: January 05, 2015, 11:49:28 AM »
It only registers in the UI when you click on something with a collider on it. This assumes you've set up your layers properly, so the UI is in its own layer and everything else is not.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ClickThrough
« Reply #2 on: January 05, 2015, 12:13:58 PM »
As Nicki pointed out, layers are key. Your UICamera sends events to everything it sees. If you set it to see all your game objects, then all your game objects will receive events.

williamian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: ClickThrough
« Reply #3 on: January 05, 2015, 12:32:14 PM »
Thanks, I think I already had that set properly, does not seem to work, let me explain-

I am using Plygame, not sure if you know it or it is part of the issue, I have a action bar set up as part of UI, I target a npc in scene, it shows a marker under feet as well a his name and health, all action s fired from bar are directed at whatever is targeted, when I click on action bar UI, the target gets de-selected leaning me to believe I am getting clickthrough.

I have the UIroot and all children on a Ui layer.

I have the Ui camera culling mask set to just UI.

I have a main camera as well set to default layer and culling everything except UI.

Am I missing something?

Thanks.



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ClickThrough
« Reply #4 on: January 05, 2015, 12:34:54 PM »
My guess is you are not using NGUI events then. What events does your Polygamy tool use? NGUI selection event is OnSelect (bool isSelected), sent by the UICamera to whatever is underneath the click. Only one thing can be selected at a time.

P.S. If you don't want your game camera to send out events, remove UICamera script from it.

williamian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: ClickThrough
« Reply #5 on: January 06, 2015, 04:19:28 PM »
I have a prefab at https://www.dropbox.com/s/z9fc8m5v5p932l6/Master-UI%201.prefab?dl=0, it has elements from a demo that do not click through and I added my actin bar that does, if someone has time to take a look and tel me what the issue is that would be great.

I have studied the working elements 6 ways to Sunday and simply cannot figure out why they work and my bar doe not, ty.
« Last Edit: January 07, 2015, 07:42:37 AM by williamian »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ClickThrough
« Reply #6 on: January 07, 2015, 01:24:01 PM »
Linking a prefab doesn't do anything. All a prefab does is references existing components, which are not a part of the prefab. You need to create a unity package instead. In any case, it's a simple matter. Either it uses NGUI events like OnClick, OnPress etc, or it doesn't. If it uses NGUI events, everything should work as expected. If it doesn't, then all bets are off. For example OnMouse* series of events are not NGUI events.

williamian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: ClickThrough
« Reply #7 on: January 07, 2015, 02:02:45 PM »
Ahh, thanks, yea, forgot that prefabs link to other things in the project.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: ClickThrough
« Reply #8 on: January 10, 2015, 05:59:35 PM »
My guess is that plygame uses an input.gettouch or input.getmouse something something to register its clicks. You need to have that look if the click was used by NGUI - you can do this by having UICamera have a fallThrough gameobject which sets a bool usedByNGUI to false whenever a mousedown (OnPress) is received by that object. It's a good idea to move the custom execution order of UICamera to be before the regular objects, so that this bool is set before the regular Input.<..> tries to do its thing.

Does this make sense to you?

williamian

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: ClickThrough
« Reply #9 on: January 10, 2015, 10:07:20 PM »
Yes, very, TY.