Author Topic: 3D object's collider fighting with scroll view  (Read 6000 times)

honeal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
3D object's collider fighting with scroll view
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D object's collider fighting with scroll view
« Reply #1 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.