Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: LightStorm 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 (http://issuetracker.unity3d.com/issues/box-collider-2d-does-not-collide-when-its-size-is-small-like-0-dot-01) 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.
-
Mhh...
-
What does this mean?
-
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.
-
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?
-
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.
-
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.
-
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.