Author Topic: 3.0.9 f4 Problem With Colliders On Scroll Views  (Read 2137 times)

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
3.0.9 f4 Problem With Colliders On Scroll Views
« on: January 22, 2014, 01:51:52 PM »
When creating scrolling lists, it's common to have 2 different types of colliders: ones on the list elements, if they are buttons, and a "catch-all" collider that allows the player to scroll from anywhere in the list, not just over the elements. With the recent changes, if the catch-all collider is on the parent object of the Scroll View it will overlap and block some of the element colliders. Some elements will be clickable and others will not.

This only occurs with the Camera Event Type set to UI. It appears to work perfectly with it set to World (presumably it respects z-value), but in this case list element colliders aren't clipped when scrolling so it's more work to go that route. For now, it's not difficult to work around this, but it's cleaner not to need a dedicated GameObject just for the collider when it can be put on the existing parent object.

This doesn't work (random elements won't be clickable):
  • Friends List (w/Collider)
    • Scroll View
      • Grid
        • Element
        • Element
        • Element
        • Element

But this does:
  • Friends List
    • Collider
    • Scroll View
      • Grid
        • Element
        • Element
        • Element
        • Element


I'm emailing a test project for this in case it's not very clear.

Markov

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: 3.0.9 f4 Problem With Colliders On Scroll Views
« Reply #1 on: January 22, 2014, 05:20:26 PM »
I have the same problem

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Re: 3.0.9 f4 Problem With Colliders On Scroll Views
« Reply #2 on: January 22, 2014, 05:27:36 PM »
Another problem helped me figure out what's probably going on here. When the UICamera Event Type is set to UI, colliders are sorted by depth to determine which one receives the event. Colliders get their depth from either widgets on the object or in it's children. I'm guessing the collider ends up at the same depth as the colliders on the elements in the list and so you get the fighting. Adding a UIWidget to the parent along with the collider and settings it's depth appropriately will probably fix the issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.9 f4 Problem With Colliders On Scroll Views
« Reply #3 on: January 22, 2014, 09:25:46 PM »
Yeah, when in UI mode, it's not a good idea to have colliders attached to simple game objects. I advise attaching them to invisible widgets instead (UIWidget).