blob: 9d202b9c448b567440f1169c272fb5a2027aae56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEditor;
namespace UIExt
{
[AddComponentMenu("UI Extensions/LayoutGroup/GridLayoutGroupExt")]
[DisallowMultipleComponent]
[CanEditMultipleObjects]
public class GridLayoutGroupExt
: UIBehaviour
, ILayoutElement
, ILayoutGroup
{
public enum ScrollMode
{
Vertical = 1,
Horizontal = 2,
Auto = 3 // both horizontal and vertical
}
public enum MovementType
{
Unrestricted, // Unrestricted movement -- can scroll forever
Elastic, // Restricted but flexible -- can go past the edges, but springs back in place
Clamped, // Restricted movement where it's not possible to go past the edges
}
[System.NonSerialized] private RectTransform m_Rect;
protected RectTransform rectTransform
{
get
{
if (m_Rect == null)
m_Rect = GetComponent<RectTransform>();
return m_Rect;
}
}
[SerializeField] private ScrollRect m_Scrollrect;
public ScrollRect scrollRect { get { return m_Scrollrect; } set { m_Scrollrect = value; } }
[SerializeField] private RectTransform m_Content;
public RectTransform content { get { return m_Content; } set { m_Content = value; } }
[SerializeField] private LayoutItem m_ItemTemplate;
public LayoutItem itemTemplate { get { return m_ItemTemplate; } set { m_ItemTemplate = value; } }
[SerializeField] private int m_RowCount;
public int rowCount { get { return m_RowCount; } set { m_RowCount = value; } }
[SerializeField] private int m_ColumCount;
public int columCount { get { return m_ColumCount; } set { m_ColumCount = value; } }
[SerializeField] protected RectOffset m_Padding = new RectOffset();
public RectOffset padding { get { return m_Padding; } set { SetProperty(ref m_Padding, value); } }
[SerializeField] private Vector2Int m_CellSize;
public Vector2Int cellSize { get { return m_CellSize; } set { m_CellSize = value; } }
[SerializeField] private Vector2Int m_Spacing;
public Vector2Int spacing { get { return m_Spacing; } set { m_Spacing = value; } }
[SerializeField] private ScrollMode m_ScrollMode = ScrollMode.Vertical;
[SerializeField] private MovementType m_MovementType = MovementType.Elastic;
private List<object> m_DataList;
public List<object> dataList { get { return m_DataList; } }
public float minWidth
{
get
{
throw new System.NotImplementedException();
}
}
public float preferredWidth { get { return 0; } }
public float flexibleWidth { get { return 0; } }
public float minHeight { get { return 0; } }
public float preferredHeight { get { return 0; } }
public float flexibleHeight { get { return 0; } }
public int layoutPriority { get { return 0; } }
public void SetList(List<object> datalist)
{
m_DataList = datalist;
}
public void MoveTo(int indexOfData)
{
}
public void MoveTo(object data)
{
}
public void CalculateLayoutInputHorizontal()
{
}
public void CalculateLayoutInputVertical()
{
}
public void SetLayoutHorizontal()
{
}
public void SetLayoutVertical()
{
}
protected void SetProperty<T>(ref T currentValue, T newValue)
{
if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
return;
currentValue = newValue;
SetDirty();
}
protected void SetDirty()
{
if (!IsActive())
return;
if (!CanvasUpdateRegistry.IsRebuildingLayout())
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
else
StartCoroutine(DelayedSetDirty(rectTransform));
}
IEnumerator DelayedSetDirty(RectTransform rectTransform)
{
yield return null;
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
}
}
}
|