版本更新,修复部分文本包裹器处理过程中可能遇到的下标错误的问题。

添加一些列表用法,如迭代直到……和直到……迭代
This commit is contained in:
2025-08-25 14:55:35 +08:00
parent 4c3f840141
commit 7ad6555795
7 changed files with 289 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using XericLibrary.Runtime.MacroLibrary;
namespace Deconstruction.UI.TmpText
@@ -17,6 +18,8 @@ namespace Deconstruction.UI.TmpText
{
private TextMeshProUGUI _tmpText;
public bool autoFixRayCastTargetState = true;
#if ODIN_INSPECTOR
[LabelText("超链接管理器*")]
#endif
@@ -56,17 +59,30 @@ namespace Deconstruction.UI.TmpText
yield return link;
}
}
private void Awake()
#if UNITY_EDITOR
protected void OnValidate()
{
_tmpText = GetComponent<TextMeshProUGUI>();
}
#endif
protected virtual void Awake()
{
if (_tmpText == null)
_tmpText = GetComponent<TextMeshProUGUI>();
if (manager == null)
transform.GetParents().Startup(transform).GetComponent(out manager);
if (manager == null)
throw new Exception("TMP文本超链接集成捕获组件必须放在具有管理器的父级下");
}
protected virtual void OnEnable()
{
if (autoFixRayCastTargetState)
_tmpText.raycastTarget = true;
}
public void OnPointerClick(PointerEventData eventData)
{
ClickPoint(eventData.position);
@@ -87,7 +103,7 @@ namespace Deconstruction.UI.TmpText
}
catch (Exception e)
{
Debug.LogError($"点击 {_tmpText.text.LimitStringLength(32)} 的超链接 {linkID} 时出错\n{e.Message}\n{e.Data}", this);
Debug.LogError($"超链接目标事件存在错误 {_tmpText.text.LimitStringLength(32)} \n{e.Message}\n{e.Data}", this);
}
}
}