1- using System ;
1+ using HypertextHelper ;
2+ using System ;
23using System . Collections . Generic ;
34using UnityEngine ;
45using UnityEngine . EventSystems ;
56using UnityEngine . UI ;
6- using HypertextHelper ;
77
88public abstract class HypertextBase : Text , IPointerClickHandler
99{
@@ -13,16 +13,16 @@ public abstract class HypertextBase : Text, IPointerClickHandler
1313
1414 struct ClickableEntry
1515 {
16- public int WordStartIndex ;
1716 public string Word ;
17+ public int StartIndex ;
1818 public Color Color ;
1919 public Action < string > OnClick ;
2020 public List < Rect > Rects ;
2121
2222 public ClickableEntry ( string word , int startIndex , Color color , Action < string > onClick )
2323 {
2424 Word = word ;
25- WordStartIndex = startIndex ;
25+ StartIndex = startIndex ;
2626 Color = color ;
2727 OnClick = onClick ;
2828 Rects = new List < Rect > ( ) ;
@@ -32,23 +32,23 @@ public ClickableEntry(string word, int startIndex, Color color, Action<string> o
3232 /// <summary>
3333 /// クリック可能領域に関する情報を登録します
3434 /// </summary>
35- /// <param name="wordStartIndex ">対象ワードの開始インデックス</param>
35+ /// <param name="startIndex ">対象ワードの開始インデックス</param>
3636 /// <param name="wordLength">対象ワードの文字数</param>
3737 /// <param name="color">対象ワードにつける色</param>
3838 /// <param name="onClick">対象ワードがクリックされたときのコールバック</param>
39- protected void RegisterClickable ( int wordStartIndex , int wordLength , Color color , Action < string > onClick )
39+ protected void RegisterClickable ( int startIndex , int wordLength , Color color , Action < string > onClick )
4040 {
4141 if ( onClick == null )
4242 {
4343 return ;
4444 }
4545
46- if ( wordStartIndex < 0 || wordLength < 0 || wordStartIndex + wordLength > text . Length )
46+ if ( startIndex < 0 || wordLength < 0 || startIndex + wordLength > text . Length )
4747 {
4848 return ;
4949 }
5050
51- _entries . Add ( new ClickableEntry ( text . Substring ( wordStartIndex , wordLength ) , wordStartIndex , color , onClick ) ) ;
51+ _entries . Add ( new ClickableEntry ( text . Substring ( startIndex , wordLength ) , startIndex , color , onClick ) ) ;
5252 }
5353
5454 /// <summary>
@@ -90,7 +90,7 @@ void Modify(ref List<UIVertex> vertices)
9090 {
9191 var entry = _entries [ i ] ;
9292
93- for ( int textIndex = entry . WordStartIndex , wordEndIndex = entry . WordStartIndex + entry . Word . Length ; textIndex < wordEndIndex ; textIndex ++ )
93+ for ( int textIndex = entry . StartIndex , wordEndIndex = entry . StartIndex + entry . Word . Length ; textIndex < wordEndIndex ; textIndex ++ )
9494 {
9595 var vertexStartIndex = textIndex * CharVertsNum ;
9696 if ( vertexStartIndex + CharVertsNum > verticesCount )
@@ -130,10 +130,7 @@ void Modify(ref List<UIVertex> vertices)
130130 }
131131 }
132132
133- var charRect = new Rect ( ) ;
134- charRect . min = min ;
135- charRect . max = max ;
136- entry . Rects . Add ( charRect ) ;
133+ entry . Rects . Add ( new Rect { min = min , max = max } ) ;
137134 }
138135
139136 // 同じ行で隣り合った矩形をまとめる
@@ -198,10 +195,7 @@ Rect MergeRects(List<Rect> rects)
198195 }
199196 }
200197
201- var rect = new Rect ( ) ;
202- rect . min = min ;
203- rect . max = max ;
204- return rect ;
198+ return new Rect { min = min , max = max } ;
205199 }
206200
207201 // TODO: Canvas の Render Mode によって localPosition の算出方法を変える
0 commit comments