{"id":14960399,"url":"https://github.com/qiankanglai/loopscrollrect","last_synced_at":"2025-05-14T03:08:52.257Z","repository":{"id":36305667,"uuid":"40610278","full_name":"qiankanglai/LoopScrollRect","owner":"qiankanglai","description":"These scripts will make your UGUI ScrollRect reusing cells, to improve performance, loading time and draw calls.","archived":false,"fork":false,"pushed_at":"2025-04-24T12:23:58.000Z","size":6482,"stargazers_count":2469,"open_issues_count":7,"forks_count":488,"subscribers_count":86,"default_branch":"master","last_synced_at":"2025-05-08T04:36:43.518Z","etag":null,"topics":["ugui","unity3d"],"latest_commit_sha":null,"homepage":"http://qiankanglai.me/2015/08/15/LoopScrollRect/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qiankanglai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-12T16:02:00.000Z","updated_at":"2025-05-06T10:35:52.000Z","dependencies_parsed_at":"2024-01-12T04:54:07.135Z","dependency_job_id":"a84d19b3-a747-4ab1-a910-fd5ec024986c","html_url":"https://github.com/qiankanglai/LoopScrollRect","commit_stats":{"total_commits":160,"total_committers":10,"mean_commits":16.0,"dds":"0.23750000000000004","last_synced_commit":"ed00b083a02b76091fd946d79b2b3ab6d3f2721f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiankanglai%2FLoopScrollRect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiankanglai%2FLoopScrollRect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiankanglai%2FLoopScrollRect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiankanglai%2FLoopScrollRect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qiankanglai","download_url":"https://codeload.github.com/qiankanglai/LoopScrollRect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059507,"owners_count":22007768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ugui","unity3d"],"created_at":"2024-09-24T13:22:11.810Z","updated_at":"2025-05-14T03:08:52.235Z","avatar_url":"https://github.com/qiankanglai.png","language":"C#","readme":"# Loop Scroll Rect\r\n\r\n[![openupm](https://img.shields.io/npm/v/me.qiankanglai.loopscrollrect?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/me.qiankanglai.loopscrollrect/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\nThese scripts help make your ScrollRect `Reusable`, because it will only build cells when needed. If you have a large number of cells in a scroll rect, you absolutely need it! It will save a lot of time loading and draw call, along with memory in use, while still working smoothly.\r\n\r\n中文说明请看[这里](http://qiankanglai.me/2015/08/15/LoopScrollRect/)。\r\n\r\n## Installation\r\n\r\nOpen Package Manager and Add package from git URL `https://github.com/qiankanglai/LoopScrollRect.git`.\r\n\r\nWith [OpenUPM](https://openupm.com/), just one command `openupm add me.qiankanglai.loopscrollrect`.\r\n\r\nWith older Unity version, just clone the repo and put into `Assets/`.\r\n\r\n## Demo\r\n\r\nDemo for Loop Scroll Rect. Each cell knows its own index, and it is able to modify its content/size/color easily.\r\n\r\nAlso ScrollBar is supported now! It supports both vertical \u0026 horizontal directions, back and forth.\r\n\r\n![Demo1](Images~/demo1.gif)\r\n\r\n![Demo2](Images~/demo2.gif)\r\n\r\nDemo without mask. As you can see, the cells are only instantiated when needed and recycled.\r\n\r\n![Demo3](Images~/demo3.gif)\r\n\r\n**New**: Scroll to Index\r\n\r\n![ScrollToIndex](Images~/ScrollToIndex.gif)\r\n\r\n## Introduction\r\n\r\nThe original idea comes from @ivomarel's [InfinityScroll](https://github.com/ivomarel/InfinityScroll). After serveral refactorisations, I almost rewrite all the codes:\r\n- Avoid using `sizeDelta` directly since it doesn't always mean size\r\n- Support GridLayout\r\n- Avoid blocking when dragging back\r\n- Take advantage of pool rather than instantiate/destroy every time\r\n- Improve some other details for performance\r\n- Supports reverse direction\r\n- **Supports ScrollBar** (this doesn't work in Infinite mode, and may behavior strange for cells with different size)\r\n\r\nMy scripts copies `ScrollRect` from [UGUI](https://bitbucket.org/Unity-Technologies/ui) rather than inherit `ScrollRect` like InfinityScroll. I need to modify some private variants to make dragging smooth. All my codes is wrapped with comments like `==========LoopScrollRect==========`, making maintaining a little easier.\r\n\r\n## Example\r\n\r\nPlease refer to `InitOnStart.cs` for quick example implmentation. It's high recommended for implmentating your own cache pool.\r\n\r\n### Infinite Version\r\n\r\nIf you need scroll infinitely, you can simply set `totalCount` to a negative number.\r\n\r\n### Quick Jump\r\n\r\nI've implemented a simple version with `Coroutine`. You can use the following API:\r\n\r\n    public void SrollToCell(int index, float speed)\r\n\r\nHere is a corner case unsolved yet: You can't jump to the last cells which cannot be pulled to the start.\r\n\r\n## Example: Loop Vertical Scroll Rect\r\n\r\nThese steps may be confusing, so you can just open the demo scene and copy \u0026 paste :D\r\n\r\nYou can also remove EasyObjPool and use your pool instead.\r\n\r\n- Prepare cell prefabs\r\n    - The cell needs `Layout Element` attached and preferred width/height\r\n    - You should add a script receiving message `void ScrollCellIndex (int idx) `\r\n\r\n![ScrollCell](Images~/ScrollCell.png)\r\n\r\n- Right click in Hierarchy and click **UI/Loop Horizontal Scroll Rect** or **UI/Loop Vertical Scroll Rect**. It is the same for these two in the Component Menu.\r\n    - Init in Start: call Refill cells automatically when Start\r\n    - Prefab Pool: the EasyObjPool gameObject\r\n    - Prefab Pool Name: the corresponding pool in step 1\r\n    - Total Count: How many cells are available (index: 0 ~ TotalCount-1)\r\n    - Threshold: How many additional pixels of content should be prepared before start or after end?\r\n    - ReverseDirection: If you want scroll from bottom or right, you should toggle this\r\n    - Clear Cells: remove existing cells and keep uninitialized\r\n    - Refill Cells: initialize and fill up cells\r\n\r\n![LoopVerticalScrollRect](Images~/LoopVerticalScrollRect.png)\r\n\r\nIf you need scroll from top or left, setting content's pivot to 1 and disable ReverseDirection. Otherwise, you should set 0 to pivot and enable ReverseDirection (I have made `VerticalScroll_Reverse` in the demo scene as reference).\r\n\r\nI highly suggests you trying these parameters by hand. More details can be found in the demo scene.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiankanglai%2Floopscrollrect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqiankanglai%2Floopscrollrect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiankanglai%2Floopscrollrect/lists"}