|
Post by moonlife on Jul 14, 2022 10:01:25 GMT
Hi,
I want to create a grid list with 2 columns in each row. I was achieving this with Grid Layout Group with built-in ScrollRect. Checked grid examples in EnhancedScroller demos, but couldn't find any examples using Grid Layout Group component, all of them creating a grid view by placing Horizontal Layout Groups in a Vertical Layout Group. I managed to get it work, but width/height aspect of my prefabs gets distorted in a Horizontal Layout Group.
Is it possible to use Grid Layout Group in EnhancedScroller, or is the only way to use Horizontal Layout Groups in Vertical Layout Group?
|
|
|
Post by moonlife on Jul 14, 2022 11:23:14 GMT
I've created a simple scene to illustrate the situation. In the left panel, locations of sub elements are distorted. In the right side, Grid Layout Group shows prefabs as intended. I can also provide this sample Unity project if you wish (only to Echo17 support mail address of course).
|
|
|
Post by echo17 on Jul 14, 2022 11:36:09 GMT
EnhancedScroller virtualizes cells, meaning that it only shows the cells that will be visible, saving resources and memory. What that also means is that it requires a single column (or row depending on your orientation) to handle the virtualization. Grid layouts don't play nice with the tradeoff of speed and reduced memory footprint. One way around this is like in the grid demo, where each cell has columns to simulate a grid. I'm not sure why your elements would be distorted, perhaps you need to increase your cell size returned in the controller's delegate method GetCellViewSize. I can certainly take a look at an example project, if you'd like. Please see this FAQ for more information: link
|
|