This project implements an recyclable list by referencing ScrollRect source code and LoopScrollRect, with the goal of completely abandoning LayoutGroup components.
If element size is fixed, use LoopScrollFixed, you should set its size field, since it will ignore item's real size. Otherwise use LoopScrollFlex.
-
Fill elements via calling
RefillCells(int offset = 0)orRefillCellsBackwards(int index). -
Listen to
onRefreshItemto draw your elements. -
Listen to
onReleaseItemif you wish to get callback when element was released to cache pool. -
Set
totalCountnegative for infinite items. -
Set element size in
onRefreshItemfor dynamic case.
-
Scrollbar may be a little jittering, since I need to update predicted total size for all elements and scrollbar value every time when element changes.
-
If you want element for auto size, functionally like
ContentSizeFitter、LayoutElment, please implement your own script to immediately resize RectTransform size inonRefreshIteminvokes. Maybe likeLayoutRebuilder.ForceRebuildLayoutImmediate. -
Won't implement dynamic size loop grid case. If you need, just group several items together as a single item and use
LoopScrollFlex.
-
Now it's simple and may lack lots of functions, but should be useable.
-
Probably will not implement for both directions since rare use cases.
-
Just padding of scroll moving direction is now not added, and probably will not afterwards.
-
DO NOT CHANGE element position along loop direction.
-
ScrollSensitivityin horizontal is negative ofScrollRect.ScrollSensitivitywhich applys to my habbit. -
For auto expand view scrollbar, I just expand view size by its pivot. So set view anchor pivot properly if you use auto hide and expand viewport scrollbar.
-
enableDragInParentlets you to pass drag events to parents.For example, if you have loop horizontals in loop vertical, you can drag vertically for the vertical loop without affecting horizontals, and drag horizontally for a horizontal loop without affecting the vertical loop. Whether it's a horizontal or vertical drag is judged inOnBeginDragby checking whick direction of dragged offset is larger. -
Common layout field values MUST be set before called
RefillCell, does not support changing when and after refilling items.