|
Post by nemoidstudio on Nov 2, 2018 15:13:46 GMT
Hello,
In my game, I currently have a Unity UI Scroll View. I was able to change and animate the size of cells by clicking on it, using the Toggle script and playing an animation on cells to update their height.
Demo video :
I'd like to replace this with Enhanced Scroller but I have not been able to reproduce the same effect: nothing happens when I click on my toggle. From what I understand it is because cells size is controlled by the EnhancedScroller. I tried to change the returned value of GetCellViewSize (inspired by demo #8) but it didn't work.
So, would it be possible to achieve this effect and how?
Thanks a lot.
|
|
|
Post by echo17 on Nov 3, 2018 13:29:41 GMT
The EnhancedScroller uses what's known as virtualization to calculate the space for all the cells. It was primarily intended to reduce the amount of cells needed to be in memory at any given time, allowing you to have millions of cells without a performance hit. In order to achieve this effect, it has to pre-calculate all the space required for the cells, even though they will not be displayed until the scroller reaches their location. This has the unfortunately tradeoff of not being able to change the cell sizes dynamically at runtime without reloading and recalculating cell sizes.
One workaround you can try is to change the value passed back in the GetCellViewSize method and then call the reload function on the scroller. You won't be able to achieve an animated effect like in your video, however, since the reload will just set the sizes all at once.
I have given much thought to this since it is probably my number one requested item, but the answer to dynamic cell sizes has eluded me so far.
|
|
|
Post by jasonw on Dec 19, 2019 21:01:29 GMT
Any update on this? I'm looking to have this same effect and was hoping to use enhancedscroller.
|
|