From 8dbabbbd89c6899e53e9389dc065d5345455e460 Mon Sep 17 00:00:00 2001 From: LiRuoChen <571244399@qq.com> Date: Fri, 27 Jun 2025 18:07:24 +0800 Subject: [PATCH] update --- Runtime/UI/TmpText.meta | 4 --- Runtime/UI/TmpText/TMPHyperlinkManager.cs | 2 +- Runtime/UI/TmpText/TMPHyperlinkReceiver.cs | 30 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Runtime/UI/TmpText.meta b/Runtime/UI/TmpText.meta index e3c9bfd..6ec62ab 100644 --- a/Runtime/UI/TmpText.meta +++ b/Runtime/UI/TmpText.meta @@ -1,9 +1,5 @@ fileFormatVersion: 2 -<<<<<<<< HEAD:Release/Samples~/ConfigUIElement.meta -guid: 7758a0679c9038144a4b0d007d44618f -======== guid: 85f1b523843f5884bb9f6b47500bccd0 ->>>>>>>> gitea-Srouce/master:Release/Runtime/UI/TmpText.meta folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/UI/TmpText/TMPHyperlinkManager.cs b/Runtime/UI/TmpText/TMPHyperlinkManager.cs index 2bde5a7..8e130c1 100644 --- a/Runtime/UI/TmpText/TMPHyperlinkManager.cs +++ b/Runtime/UI/TmpText/TMPHyperlinkManager.cs @@ -238,7 +238,7 @@ namespace Deconstruction.UI.TmpText // 尝试获取TMP_Text组件 var tmp = child.GetComponent(tmpTextType) as TMP_Text; - if (tmp != null && tmp.text.MatchRichTextID()) + if (tmp != null && tmp.text.MatchRichTextLinkID()) { result.Add(child.gameObject.AddComponent()); } diff --git a/Runtime/UI/TmpText/TMPHyperlinkReceiver.cs b/Runtime/UI/TmpText/TMPHyperlinkReceiver.cs index cce147b..7e1516d 100644 --- a/Runtime/UI/TmpText/TMPHyperlinkReceiver.cs +++ b/Runtime/UI/TmpText/TMPHyperlinkReceiver.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Sirenix.OdinInspector; using TMPro; using UnityEngine; @@ -27,6 +28,35 @@ namespace Deconstruction.UI.TmpText #endif [SerializeField] public UnityEvent onClickLink = new UnityEvent(); + + /// + /// 获取所有超链接id + /// + public IEnumerable AllLinkID + { + get + { + if (_tmpText == null || string.IsNullOrEmpty(_tmpText.text)) + yield break; + foreach (var link in _tmpText.text.MatchesRichTextLinkID()) + yield return link.id; + } + } + + /// + /// 获取所有超链接 + /// + 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() {