3
\$\begingroup\$

In Unity I am using a scroll view. It works semi-perfectly (had a lot of problems with it, don't like how the UI system works).

The content for my scroll view is a bunch of buttons aligned vertically with some spacing between them. The problem is that the scroll rect will only scroll if I'm hovering over one of the buttons. If the mouse is between two buttons, it won't scroll.

Here are some screenshots:

Hirearchy

Scroll rect

Scroll bar

Also, you may see that I'm not using the standard Scroll Rect, mine is nothing special, just disabled the dragging that is stupid to be used on non-touch devices.

\$\endgroup\$
  • \$\begingroup\$ Add Image component to your ScrollView so it looks like a background and tick RaycastTarget. Set it's color opacity to 0f and tell me if that works. \$\endgroup\$ – Jacob Jun 16 '17 at 21:20
  • \$\begingroup\$ Thanks, that worked perfectly! If you want you can reply with an actual answer and mark it as a solution. \$\endgroup\$ – user95747 Jun 16 '17 at 21:23
2
\$\begingroup\$

ScrollView by default has an Image component with a RaycastTarget enabled like on the image below.

enter image description here

In order to detect touch and clicks, UI elements need to have at least one component with RaycastTarget enabled.

Your ScrollView doesn't have the default Image background so it doesn't respond to clicks. Add Image component to your ScrollView so it looks like a background and tick RaycastTarget. Set it's color opacity to 0f and voilà :)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy