|
Post by mhardy on May 22, 2021 1:32:47 GMT
Is there a way to /not/ cache cells and simply create the entire list on start?
I have a small list but it does a lot of setup for each cell. So when scrolling it ends up running that setup a lot because GetCellView gets called so often. I only show 3 in the view port, but have 20 total. I'd like it to just create the 20 on start and be done. They're all the same type, so there's only 3 Instantiate's which is cool, but I'd actually like it to Instantiate all 20.
I tried setting the cellIdentifier on the returned cell view after the GetCellView call to see if they'd get recycled, but unfortunately your caching code only looks at the cellIdentifier of the original prefab, not the instantiated one. Maybe if there was an option to look at the instantiated cellview cellIdentifier the recycling mechanism might allow for my cells setup to only get called once. Then they get recycled and reused instead of GetCellView getting called over and over.
Something like this...
var cellView = scroller.GetCellView(CellViewPrefab) as MyItemCellView; cellView.SetData(myCellData); cellView.cellIdentifier = myCellData.Id.ToString(); // Id = 1-20, so each only gets created once and recycled
Awesome asset otherwise. I'm probably going to replace all my home grown scrollers with it! Great work.
|
|
|
Post by echo17 on May 22, 2021 10:14:09 GMT
The polling and recycling is built in at a low level, so it would be hard to circumvent without a lot of code changes.
However, there is a look ahead feature that lets you load in cells before they are visible. You could set the look ahead to a very large value which would force it to load all cells. The look ahead is pixel based, so just use a large number of pixels to say you want to view more cells.
Something like:
scroller.lookAheadBefore = 10000f; scroller.lookAheadAfter = 10000f; scroller.ReloadData();
the lookAheadBefore "looks ahead" (meaning before loading) in the up or left direction, depending on your orientation. The lookAheadAfter looks ahead in the down or right direction.
|
|
|
Post by mhardy on May 24, 2021 3:27:39 GMT
That worked perfect, thanks!
|
|