Skip to content

Commit 7edede3

Browse files
committed
Refactor
1 parent 7cc157f commit 7edede3

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

Assets/Hypertext/Scripts/HypertextBase.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void Modify(ref List<UIVertex> vertices)
140140
var mergedRects = new List<Rect>();
141141
foreach (var charRects in SplitRectsByRow(entry.Rects))
142142
{
143-
mergedRects.Add(MergeRects(charRects));
143+
mergedRects.Add(CalculateAABB(charRects));
144144
}
145145

146146
entry.Rects = mergedRects;
@@ -170,7 +170,7 @@ List<List<Rect>> SplitRectsByRow(List<Rect> rects)
170170
return rectsList;
171171
}
172172

173-
Rect MergeRects(List<Rect> rects)
173+
Rect CalculateAABB(List<Rect> rects)
174174
{
175175
var min = Vector2.one * float.MaxValue;
176176
var max = Vector2.one * float.MinValue;
@@ -222,22 +222,15 @@ void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
222222
{
223223
var localPosition = ToLocalPosition(eventData.position, eventData.pressEventCamera);
224224

225-
foreach (var entry in _entries)
225+
for (int i = 0; i < _entries.Count; i++)
226226
{
227-
if (entry.OnClick == null)
227+
for (int j = 0; j < _entries[i].Rects.Count; j++)
228228
{
229-
continue;
230-
}
231-
232-
foreach (var rect in entry.Rects)
233-
{
234-
if (!rect.Contains(localPosition))
229+
if (_entries[i].Rects[j].Contains(localPosition))
235230
{
236-
continue;
231+
_entries[i].OnClick(_entries[i].Word);
232+
break;
237233
}
238-
239-
entry.OnClick(entry.Word);
240-
break;
241234
}
242235
}
243236
}

0 commit comments

Comments
 (0)