Skip to content

Commit 652753e

Browse files
committed
first commit
0 parents  commit 652753e

36 files changed

+1653
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.DS_Store

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ViewportedLayouts
2+
3+
提供一些组件,解决在有限大小的区域内,显示和布局大量的UI对象。
4+
5+
# Install
6+
7+
## Dependencies
8+
9+
- [UniPool](https://github.com/wlgys8/UniPool)
10+
- [Log4Unity](https://github.com/wlgys8/Log4Unity)
11+
12+
13+
install by Packages/manifest.json (you must add dependencies to project by yourself in this way)
14+
```json
15+
"com.ms.ugui.viewportedlayouts":"https://github.com/wlgys8/ViewportedLayouts.git"
16+
```
17+
18+
or install by openupm (dependenceis will be resolved automaticly)
19+
20+
```
21+
openupm install com.ms.ugui.viewportedlayouts
22+
```
23+
24+
# 简单说明
25+
26+
27+
以简单的一个例子来说明:
28+
29+
```
30+
制作一个垂直线性布局、可滑动的列表。支持一万个以上的元素项。
31+
```
32+
33+
如果按照Unity传统的方式,ScrollView + VerticalLayoutGroup来制作,性能将是十分低下的。特别是创建一万个GameObject对象的代价是无法接受的。
34+
35+
本项目提供的组件,利用对象池的方式,对布局元素实现循环使用,实现高性能显示与布局。 基本规则如下 :
36+
37+
- 当元素项从非可见区域进入到可见区域时,才创建或从对象池中获取,并刷新显示状态。
38+
- 当元素项从可见区域进入到非可见区域时,回收进对象池。
39+
40+
因此,至多只需要创建`同时显示在可见区域的元素项数量`
41+
42+
# 支持的布局类型
43+
44+
## 1. SimpleLinearLayout
45+
46+
线性布局
47+
48+
## 2. SimpleFlexGridLayout
49+
50+
可伸缩式的网格布局
51+

README.md.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Common.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Common/CommonStructs.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
namespace MS.UGUI.ViewportedLayouts{
5+
6+
public enum AxisDirection{
7+
LeftToRight,
8+
RightToLeft,
9+
10+
UpToDown,
11+
DownToUp,
12+
}
13+
14+
public delegate void ItemViewUpdateEvent(int index);
15+
16+
17+
18+
}

Runtime/Common/CommonStructs.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Core.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Core/ILayoutCalculator.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace MS.UGUI.ViewportedLayouts{
6+
public interface ILayoutCalculator
7+
{
8+
/// <summary>
9+
/// 计算指定项的位置和大小
10+
/// </summary>
11+
Rect GetItemRect(int index);
12+
13+
/// <summary>
14+
/// 计算所有Item项所在的Content节点的大小
15+
/// </summary>
16+
/// <returns></returns>
17+
Rect GetContentRect();
18+
19+
int itemCount{
20+
get;set;
21+
}
22+
void GetOverlapsInViewport(Rect viewport,ISet<int> overlapsItemIndexes);
23+
24+
}
25+
}

Runtime/Core/ILayoutCalculator.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)