Author Topic: BoxCollider does not stop Input in 3.X  (Read 7317 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
BoxCollider does not stop Input in 3.X
« on: October 21, 2013, 04:27:46 PM »
Hey there,

so in order to stop Input on Buttons (and other stuff) I created in my a "STOPINPUTCOLLIDER" which is a GameObject with a Transform and only a BoxCollider; set to Trigger.
I change his Center.Z value like I want to certain values, most the time it is set to -15 so no button on screen (which have center.z values from 0 to  -10) can be touched.
This worked great for me.

NOW in 3.X I'm experiencing some weird stuff with this method. It kind of works in a different, weird and for my purposes not userfriendly way. It doesn't matter if I change the Value of the center.z, Buttons can be pressed. I managed to find out what the problem was. The Depth of the Background-Sprites of the Buttons.
When set to 0 or something negative the STOPINPUTCOLLIDER works, but as soon the Depth-Value of some sprites are set to 1 or above, the STOPINPUTCOLLIDER is ignored and every button can be touched.

Is there a solution to that or a workaround?

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #1 on: October 21, 2013, 04:36:15 PM »
I just read that changing on the Z-Axis has no effect at all. Tried that out and it seems to be true. That is really bad news. Changing Depth does NOT work for me, since changing Depth rearranges the Sprite-Draw-Order.

Please tell me there is a solution :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #2 on: October 21, 2013, 04:46:34 PM »
In 3.0.3 you can just add an empty UIWidget with a collider on it to intercept events.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #3 on: October 21, 2013, 04:50:32 PM »
I only have 3.0.2 and don't own a Professional License. A workaround for now would be great.

But I'm still interested in the empty Widget-thing. Does it just intercept the events or is it still depth-related, since I need the collider to stop the input on a certain Z-Value

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #4 on: October 21, 2013, 04:53:36 PM »
Change your UICamera to use "World" type instead of "UI" type and it will behave the same way it did in pre-3.0.2.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #5 on: October 21, 2013, 04:56:14 PM »
Uff, that saved my life.

But just for the record: where is the difference between "World" and "UI". Is it better to use the latter?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #6 on: October 22, 2013, 12:46:42 AM »
World raycasts into colliders. UI raycasts into widgets. World won't clip raycasts based on scroll views. UI will. So... world is faster. But UI is more designed for... UIs.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #7 on: October 22, 2013, 03:19:42 AM »
You can also add a full on UISprite to the collider and adjust the depth on that, just set the alpha to 0.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #8 on: October 22, 2013, 05:20:07 AM »
Ah you mean placing an "invisible" sprite with a collider above all the other ones, right?
Hm, that should work, I guess.

Anyway, thanks for the help! :)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: BoxCollider does not stop Input in 3.X
« Reply #9 on: October 22, 2013, 02:55:09 PM »
Yeah, that's what I mean. It's not pretty, but it works. If we can place a "dummy" UIWidget in future versions then that will be nicer.