@@ -31,7 +31,7 @@ public class InlineText : Text, IPointerClickHandler
3131
3232 #region 超链接
3333 [ System . Serializable ]
34- public class HrefClickEvent : UnityEvent < string > { }
34+ public class HrefClickEvent : UnityEvent < string , int > { }
3535 //点击事件监听
3636 public HrefClickEvent OnHrefClick = new HrefClickEvent ( ) ;
3737 // 超链接信息列表
@@ -323,11 +323,11 @@ private string GetOutputText()
323323 foreach ( Match match in _InputTagRegex . Matches ( text ) )
324324 {
325325 int _tempID = 0 ;
326- if ( ! string . IsNullOrEmpty ( match . Groups [ 1 ] . Value ) )
326+ if ( ! string . IsNullOrEmpty ( match . Groups [ 1 ] . Value ) && ! match . Groups [ 1 ] . Value . Equals ( "-" ) )
327327 _tempID = int . Parse ( match . Groups [ 1 ] . Value ) ;
328328 string _tempTag = match . Groups [ 2 ] . Value ;
329329 //更新超链接
330- if ( _tempID == - 1 )
330+ if ( _tempID < 0 )
331331 {
332332 _textBuilder . Append ( text . Substring ( _textIndex , match . Index - _textIndex ) ) ;
333333 _textBuilder . Append ( "<color=blue>" ) ;
@@ -338,6 +338,7 @@ private string GetOutputText()
338338
339339 var hrefInfo = new HrefInfo
340340 {
341+ id = Mathf . Abs ( _tempID ) ,
341342 startIndex = _startIndex , // 超链接里的文本起始顶点索引
342343 endIndex = _endIndex ,
343344 name = match . Groups [ 2 ] . Value
@@ -380,6 +381,8 @@ private string GetOutputText()
380381 #region 超链接信息类
381382 private class HrefInfo
382383 {
384+ public int id ;
385+
383386 public int startIndex ;
384387
385388 public int endIndex ;
@@ -406,7 +409,7 @@ public void OnPointerClick(PointerEventData eventData)
406409 {
407410 if ( boxes [ i ] . Contains ( lp ) )
408411 {
409- OnHrefClick . Invoke ( hrefInfo . name ) ;
412+ OnHrefClick . Invoke ( hrefInfo . name , hrefInfo . id ) ;
410413 return ;
411414 }
412415 }
0 commit comments