@@ -17,10 +17,10 @@ class Span
1717 public readonly Action < string > Callback ;
1818 public List < Rect > BoundingBoxes ;
1919
20- public Span ( int startIndex , int endIndex , Color color , Action < string > callback )
20+ public Span ( int startIndex , int length , Color color , Action < string > callback )
2121 {
2222 StartIndex = startIndex ;
23- Length = endIndex ;
23+ Length = length ;
2424 Color = color ;
2525 Callback = callback ;
2626 BoundingBoxes = new List < Rect > ( ) ;
@@ -52,7 +52,7 @@ const char
5252 Canvas RootCanvas => rootCanvas ?? ( rootCanvas = GetComponentInParent < Canvas > ( ) ) ;
5353
5454 /// <summary>
55- /// 指定した部分文字列にクリックイベントを登録します
55+ /// 指定した部分文字列にクリックイベントリスナを登録します
5656 /// </summary>
5757 /// <param name="startIndex">部分文字列の開始文字位置</param>
5858 /// <param name="length">部分文字列の長さ</param>
@@ -88,8 +88,8 @@ public virtual void RemoveListeners()
8888
8989 /// <summary>
9090 /// イベントリスナを追加します
91- /// テキストの変更などでイベントの再登録が必要なときにも呼び出されます
92- /// <see cref="HypertextBase.OnClick"/> を使ってクリックイベントを登録してください
91+ /// テキストの変更などでイベントリスナの再登録が必要なときにも呼び出されます
92+ /// <see cref="HypertextBase.OnClick"/> を使ってクリックイベントリスナを登録してください
9393 /// </summary>
9494 protected abstract void AddListeners ( ) ;
9595
@@ -154,8 +154,6 @@ protected override void OnPopulateMesh(VertexHelper toFill)
154154 }
155155 }
156156
157- m_DisableFontTextureRebuiltCallback = false ;
158-
159157 var vertices = verticesPool . Get ( ) ;
160158 toFill . GetUIVertexStream ( vertices ) ;
161159
@@ -168,6 +166,8 @@ protected override void OnPopulateMesh(VertexHelper toFill)
168166 toFill . Clear ( ) ;
169167 toFill . AddUIVertexTriangleStream ( vertices ) ;
170168 verticesPool . Release ( vertices ) ;
169+
170+ m_DisableFontTextureRebuiltCallback = false ;
171171 }
172172
173173 void GenerateHrefBoundingBoxes ( ref List < UIVertex > vertices )
@@ -181,9 +181,6 @@ void GenerateHrefBoundingBoxes(ref List<UIVertex> vertices)
181181 var startIndex = visibleCharIndexMap [ span . StartIndex ] ;
182182 var endIndex = visibleCharIndexMap [ span . StartIndex + span . Length - 1 ] ;
183183
184- startIndex = Mathf . Clamp ( startIndex , 0 , text . Length - 1 ) ;
185- endIndex = Mathf . Clamp ( endIndex , 0 , text . Length - 1 ) ;
186-
187184 for ( var textIndex = startIndex ; textIndex <= endIndex ; textIndex ++ )
188185 {
189186 var vertexStartIndex = textIndex * CharVerts ;
@@ -312,7 +309,7 @@ void GenerateVisibleCharIndexMap(bool verticesReduced)
312309
313310 if ( inTag )
314311 {
315- offset ++ ;
312+ offset -- ;
316313
317314 if ( character == GreaterThan )
318315 {
@@ -321,15 +318,15 @@ void GenerateVisibleCharIndexMap(bool verticesReduced)
321318 }
322319 else if ( supportRichText && character == LesserThan )
323320 {
324- offset ++ ;
321+ offset -- ;
325322 inTag = true ;
326323 }
327324 else if ( invisibleChars . Contains ( character ) )
328325 {
329- offset ++ ;
326+ offset -- ;
330327 }
331328
332- visibleCharIndexMap [ i ] = i - offset ;
329+ visibleCharIndexMap [ i ] = Mathf . Max ( 0 , i + offset ) ;
333330 }
334331 }
335332
0 commit comments