Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: honeal on January 29, 2014, 03:22:04 PM

Title: 3D object's collider fighting with scroll view
Post by: honeal on January 29, 2014, 03:22:04 PM
I have a scroll view with a grid of 3D objects. I have a box collider set to the scroll view (to intercept scrolling events) and a box collider set to the 3D objects (to intercept click events). However, the ability to click on the object is very finicky. Sometimes the object will recognize the click and other times the scroll view intercepts it. If I remove the scroll view collider the object always recognizes the click.

Am I doing this completely wrong or is there a better approach?
Title: Re: 3D object's collider fighting with scroll view
Post by: ArenMook on January 29, 2014, 10:42:53 PM
If the UICamera is set to "UI" mode, then hit detection is fully dependant on the widget depth, and colliders always use the depth of the widget they're attached to. If the collider is attached to a game object, then it will try its best to figure out what depth it should use, but if there are multiple widget children, it may not choose the right one. Safest thing to do is to use invisible widgets (UIWidget) when you need, or to ensure that you always attach colliders to widgets, not game objects.

If the UICamera is set to "World" mode, then it's all based on the distance from the hit position on the collider to the eye point of the camera.