gameObject.TryGetComponent<TMP_Text>(out m_text); } // Start is called before the first frame update void Start() { } private IEnumerator TypeWritter() { m_text.ForceMeshUpdate(); TMP_TextInfo textInfo = m_text.
脚本 usingSystem.Collections.Generic;usingDG.Tweening;//using Sirenix.OdinInspector;usingTMPro;usingUnityEngine;publicclassTMPJump:MonoBehaviour{privateTMP_Text_textTMP;privateTMP_TextInfo_textInfo;//[LabelText("是否循环")]publicboolisLoop;//[LabelText("是否改变颜色")]publicboolchangeColor;//[LabelText(...
TMP在字体变化的时候,需要对Mesh和三角形等做重运算,所有导致会有不同大小的数组产生。TMP扩充数组直接使用了Array.Resize函数,而该函数的内部实现会产生新的数组对象,从而增加了堆内存。 解决方案:TMP_TextInfo.cs文件内部可以使用缓存来改写局部逻辑。 6.5.字体显示顺序问题 后备字体(Fallback Font Assets) 顾名思...
for (int i = 0; i < textInfo.materialCount; ++i) { textInfo.meshInfo[i].Clear(); } textComponent.UpdateVertexData(TMPro.TMP_VertexDataUpdateFlags.Vertices); float timer = 0; float duration = 1 / speed; for (int i = 0; i < textInfo.characterCount; ++i) { while (timer < duratio...
获取被点击链接的信息 TMP_LinkInfo linkInfo = tmpText.textInfo.linkInfo[linkIndex]; string panelID = linkInfo.GetLinkID(); // 如 "Inventory"、"Settings" 等:contentReference[oaicite:3]{index=3} // 3. 根据 PanelID 弹出对应 UI 面板 tmpText.gameObject.SetActive(false); switch (panel...
; // 获取TextMeshPro的样式设置 TMP_TextInfo textInfo = textMeshProText.textInfo; // 遍历所有字符并设置下划线样式(实际上TextMeshPro已经提供了直接设置下划线的选项,这里仅作为示例) // 注意:这种方式并不是直接设置下划线,而是模拟下划线效果,实际使用中还是推荐直接勾选Underline选项 for (int i = 0; i ...
TextMeshPro tmp = GetComponent<TextMeshPro>(); tmp.OnPreRenderText += RingText; } private void RingText(TMP_TextInfo info) { Vector3 textCenter = Vector3.zero; int textVerticesNum = 0; foreach (var meshInfo in info.meshInfo) { for (int i = 0; i < meshInfo.vertices.Length; i+...
text里面设置这个字符串 publicvoidOnPointerClick(PointerEventData eventData) {intlinkIndex =TMP_TextUtilities.FindIntersectingLink(_desText, Input.mousePosition, eventData.pressEventCamera);if(_desText.textInfo.linkInfo.Length ==0)return; TMP_LinkInfo linkInfo=_desText.textInfo.linkInfo[linkIndex]; ...
创建100个Text(TMP),可以看到它的GC Alloc达到了1.8MB。不使用TMP,那创建100个Text呢?经过测试,产生的GC是1.0MB。 其中TextMeshProUGUI的Awake、OnEnable和.ctor都产生了大量的GC。查看代码可知,主要原因是由于 TMP_Text 和TMP_TextInfo 在创建时预创建了较多的数组变量,导致申请了较大的堆内存,另一方面,数组变量...
若仍无法满足需求,建议评估第三方解决方案如TextMeshPro的TMP_TextInfo底层API或商业插件(如Text Animator...