This commit is contained in:
2025-07-24 10:19:23 +08:00
parent b8c6890e04
commit 87d278c1e7
31 changed files with 74930 additions and 868 deletions
+31 -3
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
@@ -26,8 +27,36 @@ namespace Deconstruction.UI.TmpText
[LabelText("点击超链接时回调")]
#endif
[SerializeField]
private UnityEvent<string> _onClickLink;
public Action<string> onClickLink;
public UnityEvent<string> onClickLink = new UnityEvent<string>();
/// <summary>
/// 获取所有超链接id
/// </summary>
public IEnumerable<string> AllLinkID
{
get
{
if (_tmpText == null || string.IsNullOrEmpty(_tmpText.text))
yield break;
foreach (var link in _tmpText.text.MatchesRichTextLinkID())
yield return link.id;
}
}
/// <summary>
/// 获取所有超链接
/// </summary>
public IEnumerable<(string id, string block)> AllLinkIDWithContext
{
get
{
if (_tmpText == null || string.IsNullOrEmpty(_tmpText.text))
yield break;
foreach (var link in _tmpText.text.MatchesRichTextLinkID())
yield return link;
}
}
private void Awake()
{
@@ -54,7 +83,6 @@ namespace Deconstruction.UI.TmpText
try
{
onClickLink?.Invoke(linkID);
_onClickLink.Invoke(linkID);
manager.OnAnyLinkClick(linkID);
}
catch (Exception e)