TextMeshProUGUI.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.Rendering;
  5. using UnityEngine.UI;
  6. #pragma warning disable 0414 // Disabled a few warnings related to serialized variables not used in this script but used in the editor.
  7. namespace TMPro
  8. {
  9. [DisallowMultipleComponent]
  10. [RequireComponent(typeof(RectTransform))]
  11. [RequireComponent(typeof(CanvasRenderer))]
  12. [AddComponentMenu("UI/TextMeshPro - Text (UI)", 11)]
  13. [ExecuteAlways]
  14. [HelpURL("https://docs.unity3d.com/Packages/com.unity.textmeshpro@2.1")]
  15. public partial class TextMeshProUGUI : TMP_Text, ILayoutElement
  16. {
  17. /// <summary>
  18. /// Get the material that will be used for rendering.
  19. /// </summary>
  20. public override Material materialForRendering
  21. {
  22. get { return TMP_MaterialManager.GetMaterialForRendering(this, m_sharedMaterial); }
  23. }
  24. /// <summary>
  25. /// Determines if the size of the text container will be adjusted to fit the text object when it is first created.
  26. /// </summary>
  27. public override bool autoSizeTextContainer
  28. {
  29. get { return m_autoSizeTextContainer; }
  30. set { if (m_autoSizeTextContainer == value) return; m_autoSizeTextContainer = value; if (m_autoSizeTextContainer) { CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this); SetLayoutDirty(); } }
  31. }
  32. /// <summary>
  33. /// Reference to the Mesh used by the text object.
  34. /// </summary>
  35. public override Mesh mesh
  36. {
  37. get { return m_mesh; }
  38. }
  39. /// <summary>
  40. /// Reference to the CanvasRenderer used by the text object.
  41. /// </summary>
  42. public new CanvasRenderer canvasRenderer
  43. {
  44. get
  45. {
  46. if (m_canvasRenderer == null) m_canvasRenderer = GetComponent<CanvasRenderer>();
  47. return m_canvasRenderer;
  48. }
  49. }
  50. /// <summary>
  51. /// Anchor dampening prevents the anchor position from being adjusted unless the positional change exceeds about 40% of the width of the underline character. This essentially stabilizes the anchor position.
  52. /// </summary>
  53. //public bool anchorDampening
  54. //{
  55. // get { return m_anchorDampening; }
  56. // set { if (m_anchorDampening != value) { havePropertiesChanged = true; m_anchorDampening = value; /* ScheduleUpdate(); */ } }
  57. //}
  58. #if !UNITY_2019_3_OR_NEWER
  59. [SerializeField]
  60. private bool m_Maskable = true;
  61. #endif
  62. private bool m_isRebuildingLayout = false;
  63. private Coroutine m_DelayedGraphicRebuild;
  64. private Coroutine m_DelayedMaterialRebuild;
  65. /// <summary>
  66. /// Function called by Unity when the horizontal layout needs to be recalculated.
  67. /// </summary>
  68. public void CalculateLayoutInputHorizontal()
  69. {
  70. //Debug.Log("*** CalculateLayoutHorizontal() on Object ID: " + GetInstanceID() + " at frame: " + Time.frameCount + "***");
  71. }
  72. /// <summary>
  73. /// Function called by Unity when the vertical layout needs to be recalculated.
  74. /// </summary>
  75. public void CalculateLayoutInputVertical()
  76. {
  77. //Debug.Log("*** CalculateLayoutInputVertical() on Object ID: " + GetInstanceID() + " at frame: " + Time.frameCount + "***");
  78. }
  79. public override void SetVerticesDirty()
  80. {
  81. if (this == null || !this.IsActive())
  82. return;
  83. if (CanvasUpdateRegistry.IsRebuildingGraphics())
  84. {
  85. if (m_DelayedGraphicRebuild == null)
  86. m_DelayedGraphicRebuild = StartCoroutine(DelayedGraphicRebuild());
  87. return;
  88. }
  89. CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this);
  90. if (m_OnDirtyVertsCallback != null)
  91. m_OnDirtyVertsCallback();
  92. }
  93. /// <summary>
  94. ///
  95. /// </summary>
  96. public override void SetLayoutDirty()
  97. {
  98. m_isPreferredWidthDirty = true;
  99. m_isPreferredHeightDirty = true;
  100. if (this == null || !this.IsActive())
  101. return;
  102. LayoutRebuilder.MarkLayoutForRebuild(this.rectTransform);
  103. m_isLayoutDirty = true;
  104. if (m_OnDirtyLayoutCallback != null)
  105. m_OnDirtyLayoutCallback();
  106. }
  107. /// <summary>
  108. ///
  109. /// </summary>
  110. public override void SetMaterialDirty()
  111. {
  112. if (this == null || !this.IsActive())
  113. return;
  114. if (CanvasUpdateRegistry.IsRebuildingGraphics())
  115. {
  116. if (m_DelayedMaterialRebuild == null)
  117. m_DelayedMaterialRebuild = StartCoroutine(DelayedMaterialRebuild());
  118. return;
  119. }
  120. m_isMaterialDirty = true;
  121. CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild((ICanvasElement)this);
  122. if (m_OnDirtyMaterialCallback != null)
  123. m_OnDirtyMaterialCallback();
  124. }
  125. /// <summary>
  126. ///
  127. /// </summary>
  128. public override void SetAllDirty()
  129. {
  130. m_isInputParsingRequired = true;
  131. SetLayoutDirty();
  132. SetVerticesDirty();
  133. SetMaterialDirty();
  134. }
  135. /// <summary>
  136. /// Delay registration of text object for graphic rebuild by one frame.
  137. /// </summary>
  138. /// <returns></returns>
  139. IEnumerator DelayedGraphicRebuild()
  140. {
  141. yield return null;
  142. CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
  143. if (m_OnDirtyVertsCallback != null)
  144. m_OnDirtyVertsCallback();
  145. }
  146. /// <summary>
  147. /// Delay registration of text object for graphic rebuild by one frame.
  148. /// </summary>
  149. /// <returns></returns>
  150. IEnumerator DelayedMaterialRebuild()
  151. {
  152. yield return null;
  153. m_isMaterialDirty = true;
  154. CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
  155. if (m_OnDirtyMaterialCallback != null)
  156. m_OnDirtyMaterialCallback();
  157. }
  158. /// <summary>
  159. ///
  160. /// </summary>
  161. /// <param name="update"></param>
  162. public override void Rebuild(CanvasUpdate update)
  163. {
  164. if (this == null) return;
  165. if (update == CanvasUpdate.Prelayout)
  166. {
  167. if (m_autoSizeTextContainer)
  168. {
  169. m_rectTransform.sizeDelta = GetPreferredValues(Mathf.Infinity, Mathf.Infinity);
  170. }
  171. }
  172. else if (update == CanvasUpdate.PreRender)
  173. {
  174. OnPreRenderCanvas();
  175. if (!m_isMaterialDirty) return;
  176. UpdateMaterial();
  177. m_isMaterialDirty = false;
  178. }
  179. }
  180. /// <summary>
  181. /// Method to keep the pivot of the sub text objects in sync with the parent pivot.
  182. /// </summary>
  183. private void UpdateSubObjectPivot()
  184. {
  185. if (m_textInfo == null) return;
  186. for (int i = 1; i < m_subTextObjects.Length && m_subTextObjects[i] != null; i++)
  187. {
  188. m_subTextObjects[i].SetPivotDirty();
  189. }
  190. //m_isPivotDirty = false;
  191. }
  192. /// <summary>
  193. ///
  194. /// </summary>
  195. /// <param name="baseMaterial"></param>
  196. /// <returns></returns>
  197. public override Material GetModifiedMaterial(Material baseMaterial)
  198. {
  199. Material mat = baseMaterial;
  200. if (m_ShouldRecalculateStencil)
  201. {
  202. var rootCanvas = MaskUtilities.FindRootSortOverrideCanvas(transform);
  203. m_StencilValue = maskable ? MaskUtilities.GetStencilDepth(transform, rootCanvas) : 0;
  204. m_ShouldRecalculateStencil = false;
  205. }
  206. if (m_StencilValue > 0)
  207. {
  208. var maskMat = StencilMaterial.Add(mat, (1 << m_StencilValue) - 1, StencilOp.Keep, CompareFunction.Equal, ColorWriteMask.All, (1 << m_StencilValue) - 1, 0);
  209. StencilMaterial.Remove(m_MaskMaterial);
  210. m_MaskMaterial = maskMat;
  211. mat = m_MaskMaterial;
  212. }
  213. return mat;
  214. }
  215. /// <summary>
  216. ///
  217. /// </summary>
  218. protected override void UpdateMaterial()
  219. {
  220. //Debug.Log("*** UpdateMaterial() ***");
  221. //if (!this.IsActive())
  222. // return;
  223. if (m_sharedMaterial == null || canvasRenderer == null) return;
  224. m_canvasRenderer.materialCount = 1;
  225. m_canvasRenderer.SetMaterial(materialForRendering, 0);
  226. //m_canvasRenderer.SetTexture(m_sharedMaterial.mainTexture);
  227. }
  228. //public override void OnRebuildRequested()
  229. //{
  230. // //Debug.Log("OnRebuildRequested");
  231. // base.OnRebuildRequested();
  232. //}
  233. //public override bool Raycast(Vector2 sp, Camera eventCamera)
  234. //{
  235. // //Debug.Log("Raycast Event. ScreenPoint: " + sp);
  236. // return base.Raycast(sp, eventCamera);
  237. //}
  238. // MASKING RELATED PROPERTIES
  239. /// <summary>
  240. /// Sets the masking offset from the bounds of the object
  241. /// </summary>
  242. public Vector4 maskOffset
  243. {
  244. get { return m_maskOffset; }
  245. set { m_maskOffset = value; UpdateMask(); m_havePropertiesChanged = true; }
  246. }
  247. //public override Material defaultMaterial
  248. //{
  249. // get { Debug.Log("Default Material called."); return m_sharedMaterial; }
  250. //}
  251. //protected override void OnCanvasHierarchyChanged()
  252. //{
  253. // //Debug.Log("OnCanvasHierarchyChanged...");
  254. //}
  255. // IClippable implementation
  256. /// <summary>
  257. /// Method called when the state of a parent changes.
  258. /// </summary>
  259. public override void RecalculateClipping()
  260. {
  261. //Debug.Log("***** RecalculateClipping() *****");
  262. base.RecalculateClipping();
  263. }
  264. // IMaskable Implementation
  265. /// <summary>
  266. /// Method called when Stencil Mask needs to be updated on this element and parents.
  267. /// </summary>
  268. // public override void RecalculateMasking()
  269. // {
  270. // //Debug.Log("***** RecalculateMasking() *****");
  271. //
  272. // this.m_ShouldRecalculateStencil = true;
  273. // SetMaterialDirty();
  274. // }
  275. //public override void SetClipRect(Rect clipRect, bool validRect)
  276. //{
  277. // //Debug.Log("***** SetClipRect (" + clipRect + ", " + validRect + ") *****");
  278. // base.SetClipRect(clipRect, validRect);
  279. //}
  280. /// <summary>
  281. /// Override of the Cull function to provide for the ability to override the culling of the text object.
  282. /// </summary>
  283. /// <param name="clipRect"></param>
  284. /// <param name="validRect"></param>
  285. public override void Cull(Rect clipRect, bool validRect)
  286. {
  287. // Delay culling check in the event the text layout is dirty and geometry has to be updated.
  288. if (m_isLayoutDirty)
  289. {
  290. TMP_UpdateManager.RegisterTextElementForCullingUpdate(this);
  291. m_ClipRect = clipRect;
  292. m_ValidRect = validRect;
  293. return;
  294. }
  295. // Get compound rect for the text object and sub text objects in local canvas space.
  296. Rect rect = GetCanvasSpaceClippingRect();
  297. // No point culling if geometry bounds have no width or height.
  298. if (rect.width == 0 || rect.height == 0)
  299. return;
  300. var cull = !validRect || !clipRect.Overlaps(rect, true);
  301. if (m_canvasRenderer.cull != cull)
  302. {
  303. m_canvasRenderer.cull = cull;
  304. onCullStateChanged.Invoke(cull);
  305. OnCullingChanged();
  306. // Update any potential sub mesh objects
  307. for (int i = 1; i < m_subTextObjects.Length && m_subTextObjects[i] != null; i++)
  308. {
  309. m_subTextObjects[i].canvasRenderer.cull = cull;
  310. }
  311. }
  312. }
  313. private Rect m_ClipRect;
  314. private bool m_ValidRect;
  315. /// <summary>
  316. /// Internal function to allow delay of culling until the text geometry has been updated.
  317. /// </summary>
  318. internal override void UpdateCulling()
  319. {
  320. // Get compound rect for the text object and sub text objects in local canvas space.
  321. Rect rect = GetCanvasSpaceClippingRect();
  322. // No point culling if geometry bounds have no width or height.
  323. if (rect.width == 0 || rect.height == 0)
  324. return;
  325. var cull = !m_ValidRect || !m_ClipRect.Overlaps(rect, true);
  326. if (m_canvasRenderer.cull != cull)
  327. {
  328. m_canvasRenderer.cull = cull;
  329. onCullStateChanged.Invoke(cull);
  330. OnCullingChanged();
  331. // Update any potential sub mesh objects
  332. for (int i = 1; i < m_subTextObjects.Length && m_subTextObjects[i] != null; i++)
  333. {
  334. m_subTextObjects[i].canvasRenderer.cull = cull;
  335. }
  336. }
  337. }
  338. /*
  339. /// <summary>
  340. /// Sets the mask type
  341. /// </summary>
  342. public MaskingTypes mask
  343. {
  344. get { return m_mask; }
  345. set { m_mask = value; havePropertiesChanged = true; isMaskUpdateRequired = true; }
  346. }
  347. /// <summary>
  348. /// Set the masking offset mode (as percentage or pixels)
  349. /// </summary>
  350. public MaskingOffsetMode maskOffsetMode
  351. {
  352. get { return m_maskOffsetMode; }
  353. set { m_maskOffsetMode = value; havePropertiesChanged = true; isMaskUpdateRequired = true; }
  354. }
  355. */
  356. /*
  357. /// <summary>
  358. /// Sets the softness of the mask
  359. /// </summary>
  360. public Vector2 maskSoftness
  361. {
  362. get { return m_maskSoftness; }
  363. set { m_maskSoftness = value; havePropertiesChanged = true; isMaskUpdateRequired = true; }
  364. }
  365. /// <summary>
  366. /// Allows to move / offset the mesh vertices by a set amount
  367. /// </summary>
  368. public Vector2 vertexOffset
  369. {
  370. get { return m_vertexOffset; }
  371. set { m_vertexOffset = value; havePropertiesChanged = true; isMaskUpdateRequired = true; }
  372. }
  373. */
  374. /// <summary>
  375. /// Function to be used to force recomputing of character padding when Shader / Material properties have been changed via script.
  376. /// </summary>
  377. public override void UpdateMeshPadding()
  378. {
  379. m_padding = ShaderUtilities.GetPadding(m_sharedMaterial, m_enableExtraPadding, m_isUsingBold);
  380. m_isMaskingEnabled = ShaderUtilities.IsMaskingEnabled(m_sharedMaterial);
  381. m_havePropertiesChanged = true;
  382. checkPaddingRequired = false;
  383. // Return if text object is not awake yet.
  384. if (m_textInfo == null) return;
  385. // Update sub text objects
  386. for (int i = 1; i < m_textInfo.materialCount; i++)
  387. m_subTextObjects[i].UpdateMeshPadding(m_enableExtraPadding, m_isUsingBold);
  388. }
  389. /// <summary>
  390. /// Tweens the CanvasRenderer color associated with this Graphic.
  391. /// </summary>
  392. /// <param name="targetColor">Target color.</param>
  393. /// <param name="duration">Tween duration.</param>
  394. /// <param name="ignoreTimeScale">Should ignore Time.scale?</param>
  395. /// <param name="useAlpha">Should also Tween the alpha channel?</param>
  396. protected override void InternalCrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
  397. {
  398. if (m_textInfo == null)
  399. return;
  400. int materialCount = m_textInfo.materialCount;
  401. for (int i = 1; i < materialCount; i++)
  402. {
  403. m_subTextObjects[i].CrossFadeColor(targetColor, duration, ignoreTimeScale, useAlpha);
  404. }
  405. }
  406. /// <summary>
  407. /// Tweens the alpha of the CanvasRenderer color associated with this Graphic.
  408. /// </summary>
  409. /// <param name="alpha">Target alpha.</param>
  410. /// <param name="duration">Duration of the tween in seconds.</param>
  411. /// <param name="ignoreTimeScale">Should ignore Time.scale?</param>
  412. protected override void InternalCrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
  413. {
  414. if (m_textInfo == null)
  415. return;
  416. int materialCount = m_textInfo.materialCount;
  417. for (int i = 1; i < materialCount; i++)
  418. {
  419. m_subTextObjects[i].CrossFadeAlpha(alpha, duration, ignoreTimeScale);
  420. }
  421. }
  422. /// <summary>
  423. /// Function to force regeneration of the text object before its normal process time. This is useful when changes to the text object properties need to be applied immediately.
  424. /// </summary>
  425. /// <param name="ignoreActiveState">Ignore Active State of text objects. Inactive objects are ignored by default.</param>
  426. /// <param name="forceTextReparsing">Force re-parsing of the text.</param>
  427. public override void ForceMeshUpdate(bool ignoreActiveState = false, bool forceTextReparsing = false)
  428. {
  429. m_havePropertiesChanged = true;
  430. m_ignoreActiveState = ignoreActiveState;
  431. m_isInputParsingRequired = m_isInputParsingRequired ? true : forceTextReparsing;
  432. // Special handling in the event the Canvas is only disabled
  433. if (m_canvas == null)
  434. m_canvas = GetComponentInParent<Canvas>();
  435. OnPreRenderCanvas();
  436. }
  437. /// <summary>
  438. /// Function used to evaluate the length of a text string.
  439. /// </summary>
  440. /// <param name="text"></param>
  441. /// <returns></returns>
  442. public override TMP_TextInfo GetTextInfo(string text)
  443. {
  444. StringToInternalParsingBuffer(text, ref m_InternalParsingBuffer);
  445. SetArraySizes(m_InternalParsingBuffer);
  446. m_renderMode = TextRenderFlags.DontRender;
  447. ComputeMarginSize();
  448. // Need to make sure we have a valid reference to a Canvas.
  449. if (m_canvas == null) m_canvas = this.canvas;
  450. GenerateTextMesh();
  451. m_renderMode = TextRenderFlags.Render;
  452. return this.textInfo;
  453. }
  454. /// <summary>
  455. /// Function to clear the geometry of the Primary and Sub Text objects.
  456. /// </summary>
  457. public override void ClearMesh()
  458. {
  459. m_canvasRenderer.SetMesh(null);
  460. for (int i = 1; i < m_subTextObjects.Length && m_subTextObjects[i] != null; i++)
  461. m_subTextObjects[i].canvasRenderer.SetMesh(null);
  462. //if (m_linkedTextComponent != null)
  463. // m_linkedTextComponent.ClearMesh();
  464. }
  465. /// <summary>
  466. /// Event to allow users to modify the content of the text info before the text is rendered.
  467. /// </summary>
  468. public override event Action<TMP_TextInfo> OnPreRenderText;
  469. /// <summary>
  470. /// Function to update the geometry of the main and sub text objects.
  471. /// </summary>
  472. /// <param name="mesh"></param>
  473. /// <param name="index"></param>
  474. public override void UpdateGeometry(Mesh mesh, int index)
  475. {
  476. mesh.RecalculateBounds();
  477. if (index == 0)
  478. {
  479. m_canvasRenderer.SetMesh(mesh);
  480. }
  481. else
  482. {
  483. m_subTextObjects[index].canvasRenderer.SetMesh(mesh);
  484. }
  485. }
  486. /// <summary>
  487. /// Function to upload the updated vertex data and renderer.
  488. /// </summary>
  489. public override void UpdateVertexData(TMP_VertexDataUpdateFlags flags)
  490. {
  491. int materialCount = m_textInfo.materialCount;
  492. for (int i = 0; i < materialCount; i++)
  493. {
  494. Mesh mesh;
  495. if (i == 0)
  496. mesh = m_mesh;
  497. else
  498. {
  499. // Clear unused vertices
  500. // TODO: Causes issues when sorting geometry as last vertex data attribute get wiped out.
  501. //m_textInfo.meshInfo[i].ClearUnusedVertices();
  502. mesh = m_subTextObjects[i].mesh;
  503. }
  504. if ((flags & TMP_VertexDataUpdateFlags.Vertices) == TMP_VertexDataUpdateFlags.Vertices)
  505. mesh.vertices = m_textInfo.meshInfo[i].vertices;
  506. if ((flags & TMP_VertexDataUpdateFlags.Uv0) == TMP_VertexDataUpdateFlags.Uv0)
  507. mesh.uv = m_textInfo.meshInfo[i].uvs0;
  508. if ((flags & TMP_VertexDataUpdateFlags.Uv2) == TMP_VertexDataUpdateFlags.Uv2)
  509. mesh.uv2 = m_textInfo.meshInfo[i].uvs2;
  510. //if ((flags & TMP_VertexDataUpdateFlags.Uv4) == TMP_VertexDataUpdateFlags.Uv4)
  511. // mesh.uv4 = m_textInfo.meshInfo[i].uvs4;
  512. if ((flags & TMP_VertexDataUpdateFlags.Colors32) == TMP_VertexDataUpdateFlags.Colors32)
  513. mesh.colors32 = m_textInfo.meshInfo[i].colors32;
  514. mesh.RecalculateBounds();
  515. if (i == 0)
  516. m_canvasRenderer.SetMesh(mesh);
  517. else
  518. m_subTextObjects[i].canvasRenderer.SetMesh(mesh);
  519. }
  520. }
  521. /// <summary>
  522. /// Function to upload the updated vertex data and renderer.
  523. /// </summary>
  524. public override void UpdateVertexData()
  525. {
  526. int materialCount = m_textInfo.materialCount;
  527. for (int i = 0; i < materialCount; i++)
  528. {
  529. Mesh mesh;
  530. if (i == 0)
  531. mesh = m_mesh;
  532. else
  533. {
  534. // Clear unused vertices
  535. m_textInfo.meshInfo[i].ClearUnusedVertices();
  536. mesh = m_subTextObjects[i].mesh;
  537. }
  538. //mesh.MarkDynamic();
  539. mesh.vertices = m_textInfo.meshInfo[i].vertices;
  540. mesh.uv = m_textInfo.meshInfo[i].uvs0;
  541. mesh.uv2 = m_textInfo.meshInfo[i].uvs2;
  542. //mesh.uv4 = m_textInfo.meshInfo[i].uvs4;
  543. mesh.colors32 = m_textInfo.meshInfo[i].colors32;
  544. mesh.RecalculateBounds();
  545. if (i == 0)
  546. m_canvasRenderer.SetMesh(mesh);
  547. else
  548. m_subTextObjects[i].canvasRenderer.SetMesh(mesh);
  549. }
  550. }
  551. public void UpdateFontAsset()
  552. {
  553. LoadFontAsset();
  554. }
  555. }
  556. }