Author Topic: Problems with BoxCollider2D and Unity v4.5.0f6!!!  (Read 10161 times)

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Problems with BoxCollider2D and Unity v4.5.0f6!!!
« on: June 02, 2014, 06:52:27 AM »
Hi all.
Today I've updated my Unity v4.3 to latest 4.5.0f version and noticed that some GameObjects inside NGUI Root with BoxCollider2D component doesn't receive any events (OnClick, OnHover and etc). In my project each BoxCollider2D with width or height smaller than 20 just dissapeared from EditorView and don't working anymore. After some investigation I've found this link. It looks that it is impossible to use BoxCollider2D with Unity v4.5.0f6 without problems. :(

Aren, could you please stick this warning so other people would know about this nasty bug in Unity.
« Last Edit: June 02, 2014, 12:02:14 PM by LightStorm »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #1 on: June 02, 2014, 10:38:17 PM »
Mhh...

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #2 on: June 03, 2014, 01:01:47 AM »
What does this mean?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #3 on: June 04, 2014, 12:27:55 AM »
It's me expressing my frustration with Unity's recent half-untested features that break whenever someone sneezes. Unfortunately there is nothing I can do here as the issue is on Unity's side. For now, stick to 3D colliders.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #4 on: June 10, 2014, 03:57:02 AM »
AFAIK, there is no way to have unusual shapes with 3D colliders. Our game uses a lot of unusual shapes, so it's a major hurdle for us with NGUI not supporting Collider2D.

We're not using any 0.01 sized colliders... is there a way to patch in support for Collider2D?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #5 on: June 11, 2014, 04:35:44 AM »
All NGUI widgets have a custom visibility check you can set by simply setting a delegate function (UIWidget.hitCheck). Check the Useful Stuff sticky for an alpha-test example. The collider may be square, but you can refine this shape using the hit check delegate.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #6 on: June 11, 2014, 05:12:54 PM »
That's a great feature. Thanks for the tip.

Though I'm wondering if it will work when the UIWidgets' square colliders overlap; Even though the custom shapes do not. I was thinking i might have to just have one giant button and then calculate which button they were over and simulate pressing it, but I'll give that hitCheck a look.

The other reason we wanted a 2D collider was so we could use a PolygonCollider2D with UIDragDropItem "receiving area". However, my current hack is working okay. I use a square collider for the first pass, and then check with OverlapPoint using the polygon collider for a second pass.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with BoxCollider2D and Unity v4.5.0f6!!!
« Reply #7 on: June 12, 2014, 02:30:39 AM »
Yes, it will work. This hit test is used by the event system, so if your function returns 'false' (no hit), then the event system will go to the next object in line.