LoopScrollRect icon indicating copy to clipboard operation
LoopScrollRect copied to clipboard

A bug that dynamically adds Cells in GridLayout that does not show Cells in certain situations

Open suhyunrim opened this issue 1 year ago • 3 comments

Hello. I'd like to ask you about two issues.

  1. GridLayoutGroup is adding cells over time. If the cells overlap the Viewport size here, the second cell from that line will not be seen. Add the following code to InitOnStart and it will be reproduced in DemoSceneSingle. Please refer to the video.
        private float elapsedTime = 0;
        private void Update()
        {
            elapsedTime += Time.deltaTime;

            if (totalCount < 50 && elapsedTime >= 0.1f)
            {
                elapsedTime = 0;
                totalCount++;

                var scrollRect = GetComponent<LoopScrollRect>();
                scrollRect.totalCount = totalCount;
                scrollRect.RefreshCells();
            }
        }

https://github.com/user-attachments/assets/8339ccfd-3d25-4d12-a6ca-c03fc46d577b

  1. Following Logic 1, Cells were added to add a logic that scrolls when it exceeds the Viewport size. This solves Issue 1 (not a fundamental solution), but creates an issue that Cells are not recycled. Likewise, add the following code to InitOnStart and reproduce it in DemoSceneSingle. Please refer to the video.
        private float elapsedTime = 0;

        private void Update()
        {
            elapsedTime += Time.deltaTime;

            if (totalCount < 50 && elapsedTime >= 0.1f)
            {
                elapsedTime = 0;
                totalCount++;

                var scrollRect = GetComponent<LoopScrollRect>();
                scrollRect.totalCount = totalCount;
                scrollRect.RefreshCells();
                if (totalCount % 4 == 1)
                    scrollRect.ScrollToCellWithinTime(totalCount - 1, 0.5f);
            }
        }

https://github.com/user-attachments/assets/b999e100-4c27-4273-a0d3-89e4102c830f

suhyunrim avatar Aug 06 '24 12:08 suhyunrim