Scroll View/ScrollRect with 2 content folders?

Hi,

I am creating an inventory, and I am using a ScrollRect to display the items. I am currently using 2 content folders (children of the viewport with Grid Layout Group and Content Size Fitter components attached) that display the children in a grid. One of the content folders contains the grid background, and the other contains the inventory items. Interestingly, the ScrollRect does display both of them with proper sizing in the grid layout I have set according to cell size, but when I go to scroll the scrollview, only the background scrolls, not the items (presumably because the background content folder is the one I have set in the scrollview).

Is there a way to link the other folder so they both scroll? In all other respects, it works perfectly. The only other solution to this problem I can see would be to use one content folder, and blend the images so that i have one image that contains the inventory item and the background, but that seems very complicated, and if I can link the scrolling of the other folder, I should have a perfectly functioning system.

Has anyone had to deal with multiple content folders on a single ScrollView? Is there any support for a use case like this?

Use an empty gameobject that scrolls, and make both of your “folders” children of that object so that they’ll move when it moves.

You’ll need to ensure the size of the empty parent object matches the size of the content that you want to scroll through. Depending on the nature of the content, you may be able to accomplish that simply by attaching a ContentSizeFitter or some kind of layout group. (Give one of your “folders” a Layout Element component with the “ignore layout” box checked to prevent the layout group from moving or resizing it.)

That worked for me! I just used an empty GO as a parent, added a ContentSizeFitter, set the scrollview.content to the recttransform of the parent GO, and it worked! Thanks so much for your help!

1 Like