TMP_TextSelector_B.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3. using UnityEngine.EventSystems;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. #pragma warning disable 0618 // Disabled warning due to SetVertices being deprecated until new release with SetMesh() is available.
  7. namespace TMPro.Examples
  8. {
  9. public class TMP_TextSelector_B : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler, IPointerUpHandler
  10. {
  11. public RectTransform TextPopup_Prefab_01;
  12. private RectTransform m_TextPopup_RectTransform;
  13. private TextMeshProUGUI m_TextPopup_TMPComponent;
  14. private const string k_LinkText = "You have selected link <#ffff00>";
  15. private const string k_WordText = "Word Index: <#ffff00>";
  16. private TextMeshProUGUI m_TextMeshPro;
  17. private Canvas m_Canvas;
  18. private Camera m_Camera;
  19. // Flags
  20. private bool isHoveringObject;
  21. private int m_selectedWord = -1;
  22. private int m_selectedLink = -1;
  23. private int m_lastIndex = -1;
  24. private Matrix4x4 m_matrix;
  25. private TMP_MeshInfo[] m_cachedMeshInfoVertexData;
  26. void Awake()
  27. {
  28. m_TextMeshPro = gameObject.GetComponent<TextMeshProUGUI>();
  29. m_Canvas = gameObject.GetComponentInParent<Canvas>();
  30. // Get a reference to the camera if Canvas Render Mode is not ScreenSpace Overlay.
  31. if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
  32. m_Camera = null;
  33. else
  34. m_Camera = m_Canvas.worldCamera;
  35. // Create pop-up text object which is used to show the link information.
  36. m_TextPopup_RectTransform = Instantiate(TextPopup_Prefab_01) as RectTransform;
  37. m_TextPopup_RectTransform.SetParent(m_Canvas.transform, false);
  38. m_TextPopup_TMPComponent = m_TextPopup_RectTransform.GetComponentInChildren<TextMeshProUGUI>();
  39. m_TextPopup_RectTransform.gameObject.SetActive(false);
  40. }
  41. void OnEnable()
  42. {
  43. // Subscribe to event fired when text object has been regenerated.
  44. TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
  45. }
  46. void OnDisable()
  47. {
  48. // UnSubscribe to event fired when text object has been regenerated.
  49. TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
  50. }
  51. void ON_TEXT_CHANGED(Object obj)
  52. {
  53. if (obj == m_TextMeshPro)
  54. {
  55. // Update cached vertex data.
  56. m_cachedMeshInfoVertexData = m_TextMeshPro.textInfo.CopyMeshInfoVertexData();
  57. }
  58. }
  59. void LateUpdate()
  60. {
  61. if (isHoveringObject)
  62. {
  63. // Check if Mouse Intersects any of the characters. If so, assign a random color.
  64. #region Handle Character Selection
  65. int charIndex = TMP_TextUtilities.FindIntersectingCharacter(m_TextMeshPro, Input.mousePosition, m_Camera, true);
  66. // Undo Swap and Vertex Attribute changes.
  67. if (charIndex == -1 || charIndex != m_lastIndex)
  68. {
  69. RestoreCachedVertexAttributes(m_lastIndex);
  70. m_lastIndex = -1;
  71. }
  72. if (charIndex != -1 && charIndex != m_lastIndex && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
  73. {
  74. m_lastIndex = charIndex;
  75. // Get the index of the material / sub text object used by this character.
  76. int materialIndex = m_TextMeshPro.textInfo.characterInfo[charIndex].materialReferenceIndex;
  77. // Get the index of the first vertex of the selected character.
  78. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[charIndex].vertexIndex;
  79. // Get a reference to the vertices array.
  80. Vector3[] vertices = m_TextMeshPro.textInfo.meshInfo[materialIndex].vertices;
  81. // Determine the center point of the character.
  82. Vector2 charMidBasline = (vertices[vertexIndex + 0] + vertices[vertexIndex + 2]) / 2;
  83. // Need to translate all 4 vertices of the character to aligned with middle of character / baseline.
  84. // This is needed so the matrix TRS is applied at the origin for each character.
  85. Vector3 offset = charMidBasline;
  86. // Translate the character to the middle baseline.
  87. vertices[vertexIndex + 0] = vertices[vertexIndex + 0] - offset;
  88. vertices[vertexIndex + 1] = vertices[vertexIndex + 1] - offset;
  89. vertices[vertexIndex + 2] = vertices[vertexIndex + 2] - offset;
  90. vertices[vertexIndex + 3] = vertices[vertexIndex + 3] - offset;
  91. float zoomFactor = 1.5f;
  92. // Setup the Matrix for the scale change.
  93. m_matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * zoomFactor);
  94. // Apply Matrix operation on the given character.
  95. vertices[vertexIndex + 0] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 0]);
  96. vertices[vertexIndex + 1] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 1]);
  97. vertices[vertexIndex + 2] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 2]);
  98. vertices[vertexIndex + 3] = m_matrix.MultiplyPoint3x4(vertices[vertexIndex + 3]);
  99. // Translate the character back to its original position.
  100. vertices[vertexIndex + 0] = vertices[vertexIndex + 0] + offset;
  101. vertices[vertexIndex + 1] = vertices[vertexIndex + 1] + offset;
  102. vertices[vertexIndex + 2] = vertices[vertexIndex + 2] + offset;
  103. vertices[vertexIndex + 3] = vertices[vertexIndex + 3] + offset;
  104. // Change Vertex Colors of the highlighted character
  105. Color32 c = new Color32(255, 255, 192, 255);
  106. // Get a reference to the vertex color
  107. Color32[] vertexColors = m_TextMeshPro.textInfo.meshInfo[materialIndex].colors32;
  108. vertexColors[vertexIndex + 0] = c;
  109. vertexColors[vertexIndex + 1] = c;
  110. vertexColors[vertexIndex + 2] = c;
  111. vertexColors[vertexIndex + 3] = c;
  112. // Get a reference to the meshInfo of the selected character.
  113. TMP_MeshInfo meshInfo = m_TextMeshPro.textInfo.meshInfo[materialIndex];
  114. // Get the index of the last character's vertex attributes.
  115. int lastVertexIndex = vertices.Length - 4;
  116. // Swap the current character's vertex attributes with those of the last element in the vertex attribute arrays.
  117. // We do this to make sure this character is rendered last and over other characters.
  118. meshInfo.SwapVertexData(vertexIndex, lastVertexIndex);
  119. // Need to update the appropriate
  120. m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
  121. }
  122. #endregion
  123. #region Word Selection Handling
  124. //Check if Mouse intersects any words and if so assign a random color to that word.
  125. int wordIndex = TMP_TextUtilities.FindIntersectingWord(m_TextMeshPro, Input.mousePosition, m_Camera);
  126. // Clear previous word selection.
  127. if (m_TextPopup_RectTransform != null && m_selectedWord != -1 && (wordIndex == -1 || wordIndex != m_selectedWord))
  128. {
  129. TMP_WordInfo wInfo = m_TextMeshPro.textInfo.wordInfo[m_selectedWord];
  130. // Iterate through each of the characters of the word.
  131. for (int i = 0; i < wInfo.characterCount; i++)
  132. {
  133. int characterIndex = wInfo.firstCharacterIndex + i;
  134. // Get the index of the material / sub text object used by this character.
  135. int meshIndex = m_TextMeshPro.textInfo.characterInfo[characterIndex].materialReferenceIndex;
  136. // Get the index of the first vertex of this character.
  137. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[characterIndex].vertexIndex;
  138. // Get a reference to the vertex color
  139. Color32[] vertexColors = m_TextMeshPro.textInfo.meshInfo[meshIndex].colors32;
  140. Color32 c = vertexColors[vertexIndex + 0].Tint(1.33333f);
  141. vertexColors[vertexIndex + 0] = c;
  142. vertexColors[vertexIndex + 1] = c;
  143. vertexColors[vertexIndex + 2] = c;
  144. vertexColors[vertexIndex + 3] = c;
  145. }
  146. // Update Geometry
  147. m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
  148. m_selectedWord = -1;
  149. }
  150. // Word Selection Handling
  151. if (wordIndex != -1 && wordIndex != m_selectedWord && !(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
  152. {
  153. m_selectedWord = wordIndex;
  154. TMP_WordInfo wInfo = m_TextMeshPro.textInfo.wordInfo[wordIndex];
  155. // Iterate through each of the characters of the word.
  156. for (int i = 0; i < wInfo.characterCount; i++)
  157. {
  158. int characterIndex = wInfo.firstCharacterIndex + i;
  159. // Get the index of the material / sub text object used by this character.
  160. int meshIndex = m_TextMeshPro.textInfo.characterInfo[characterIndex].materialReferenceIndex;
  161. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[characterIndex].vertexIndex;
  162. // Get a reference to the vertex color
  163. Color32[] vertexColors = m_TextMeshPro.textInfo.meshInfo[meshIndex].colors32;
  164. Color32 c = vertexColors[vertexIndex + 0].Tint(0.75f);
  165. vertexColors[vertexIndex + 0] = c;
  166. vertexColors[vertexIndex + 1] = c;
  167. vertexColors[vertexIndex + 2] = c;
  168. vertexColors[vertexIndex + 3] = c;
  169. }
  170. // Update Geometry
  171. m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
  172. }
  173. #endregion
  174. #region Example of Link Handling
  175. // Check if mouse intersects with any links.
  176. int linkIndex = TMP_TextUtilities.FindIntersectingLink(m_TextMeshPro, Input.mousePosition, m_Camera);
  177. // Clear previous link selection if one existed.
  178. if ((linkIndex == -1 && m_selectedLink != -1) || linkIndex != m_selectedLink)
  179. {
  180. m_TextPopup_RectTransform.gameObject.SetActive(false);
  181. m_selectedLink = -1;
  182. }
  183. // Handle new Link selection.
  184. if (linkIndex != -1 && linkIndex != m_selectedLink)
  185. {
  186. m_selectedLink = linkIndex;
  187. TMP_LinkInfo linkInfo = m_TextMeshPro.textInfo.linkInfo[linkIndex];
  188. // Debug.Log("Link ID: \"" + linkInfo.GetLinkID() + "\" Link Text: \"" + linkInfo.GetLinkText() + "\""); // Example of how to retrieve the Link ID and Link Text.
  189. Vector3 worldPointInRectangle;
  190. RectTransformUtility.ScreenPointToWorldPointInRectangle(m_TextMeshPro.rectTransform, Input.mousePosition, m_Camera, out worldPointInRectangle);
  191. switch (linkInfo.GetLinkID())
  192. {
  193. case "id_01": // 100041637: // id_01
  194. m_TextPopup_RectTransform.position = worldPointInRectangle;
  195. m_TextPopup_RectTransform.gameObject.SetActive(true);
  196. m_TextPopup_TMPComponent.text = k_LinkText + " ID 01";
  197. break;
  198. case "id_02": // 100041638: // id_02
  199. m_TextPopup_RectTransform.position = worldPointInRectangle;
  200. m_TextPopup_RectTransform.gameObject.SetActive(true);
  201. m_TextPopup_TMPComponent.text = k_LinkText + " ID 02";
  202. break;
  203. }
  204. }
  205. #endregion
  206. }
  207. else
  208. {
  209. // Restore any character that may have been modified
  210. if (m_lastIndex != -1)
  211. {
  212. RestoreCachedVertexAttributes(m_lastIndex);
  213. m_lastIndex = -1;
  214. }
  215. }
  216. }
  217. public void OnPointerEnter(PointerEventData eventData)
  218. {
  219. //Debug.Log("OnPointerEnter()");
  220. isHoveringObject = true;
  221. }
  222. public void OnPointerExit(PointerEventData eventData)
  223. {
  224. //Debug.Log("OnPointerExit()");
  225. isHoveringObject = false;
  226. }
  227. public void OnPointerClick(PointerEventData eventData)
  228. {
  229. //Debug.Log("Click at POS: " + eventData.position + " World POS: " + eventData.worldPosition);
  230. // Check if Mouse Intersects any of the characters. If so, assign a random color.
  231. #region Character Selection Handling
  232. /*
  233. int charIndex = TMP_TextUtilities.FindIntersectingCharacter(m_TextMeshPro, Input.mousePosition, m_Camera, true);
  234. if (charIndex != -1 && charIndex != m_lastIndex)
  235. {
  236. //Debug.Log("Character [" + m_TextMeshPro.textInfo.characterInfo[index].character + "] was selected at POS: " + eventData.position);
  237. m_lastIndex = charIndex;
  238. Color32 c = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255);
  239. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[charIndex].vertexIndex;
  240. UIVertex[] uiVertices = m_TextMeshPro.textInfo.meshInfo.uiVertices;
  241. uiVertices[vertexIndex + 0].color = c;
  242. uiVertices[vertexIndex + 1].color = c;
  243. uiVertices[vertexIndex + 2].color = c;
  244. uiVertices[vertexIndex + 3].color = c;
  245. m_TextMeshPro.canvasRenderer.SetVertices(uiVertices, uiVertices.Length);
  246. }
  247. */
  248. #endregion
  249. #region Word Selection Handling
  250. //Check if Mouse intersects any words and if so assign a random color to that word.
  251. /*
  252. int wordIndex = TMP_TextUtilities.FindIntersectingWord(m_TextMeshPro, Input.mousePosition, m_Camera);
  253. // Clear previous word selection.
  254. if (m_TextPopup_RectTransform != null && m_selectedWord != -1 && (wordIndex == -1 || wordIndex != m_selectedWord))
  255. {
  256. TMP_WordInfo wInfo = m_TextMeshPro.textInfo.wordInfo[m_selectedWord];
  257. // Get a reference to the uiVertices array.
  258. UIVertex[] uiVertices = m_TextMeshPro.textInfo.meshInfo.uiVertices;
  259. // Iterate through each of the characters of the word.
  260. for (int i = 0; i < wInfo.characterCount; i++)
  261. {
  262. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[wInfo.firstCharacterIndex + i].vertexIndex;
  263. Color32 c = uiVertices[vertexIndex + 0].color.Tint(1.33333f);
  264. uiVertices[vertexIndex + 0].color = c;
  265. uiVertices[vertexIndex + 1].color = c;
  266. uiVertices[vertexIndex + 2].color = c;
  267. uiVertices[vertexIndex + 3].color = c;
  268. }
  269. m_TextMeshPro.canvasRenderer.SetVertices(uiVertices, uiVertices.Length);
  270. m_selectedWord = -1;
  271. }
  272. // Handle word selection
  273. if (wordIndex != -1 && wordIndex != m_selectedWord)
  274. {
  275. m_selectedWord = wordIndex;
  276. TMP_WordInfo wInfo = m_TextMeshPro.textInfo.wordInfo[wordIndex];
  277. // Get a reference to the uiVertices array.
  278. UIVertex[] uiVertices = m_TextMeshPro.textInfo.meshInfo.uiVertices;
  279. // Iterate through each of the characters of the word.
  280. for (int i = 0; i < wInfo.characterCount; i++)
  281. {
  282. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[wInfo.firstCharacterIndex + i].vertexIndex;
  283. Color32 c = uiVertices[vertexIndex + 0].color.Tint(0.75f);
  284. uiVertices[vertexIndex + 0].color = c;
  285. uiVertices[vertexIndex + 1].color = c;
  286. uiVertices[vertexIndex + 2].color = c;
  287. uiVertices[vertexIndex + 3].color = c;
  288. }
  289. m_TextMeshPro.canvasRenderer.SetVertices(uiVertices, uiVertices.Length);
  290. }
  291. */
  292. #endregion
  293. #region Link Selection Handling
  294. /*
  295. // Check if Mouse intersects any words and if so assign a random color to that word.
  296. int linkIndex = TMP_TextUtilities.FindIntersectingLink(m_TextMeshPro, Input.mousePosition, m_Camera);
  297. if (linkIndex != -1)
  298. {
  299. TMP_LinkInfo linkInfo = m_TextMeshPro.textInfo.linkInfo[linkIndex];
  300. int linkHashCode = linkInfo.hashCode;
  301. //Debug.Log(TMP_TextUtilities.GetSimpleHashCode("id_02"));
  302. switch (linkHashCode)
  303. {
  304. case 291445: // id_01
  305. if (m_LinkObject01 == null)
  306. m_LinkObject01 = Instantiate(Link_01_Prefab);
  307. else
  308. {
  309. m_LinkObject01.gameObject.SetActive(true);
  310. }
  311. break;
  312. case 291446: // id_02
  313. break;
  314. }
  315. // Example of how to modify vertex attributes like colors
  316. #region Vertex Attribute Modification Example
  317. UIVertex[] uiVertices = m_TextMeshPro.textInfo.meshInfo.uiVertices;
  318. Color32 c = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255);
  319. for (int i = 0; i < linkInfo.characterCount; i++)
  320. {
  321. TMP_CharacterInfo cInfo = m_TextMeshPro.textInfo.characterInfo[linkInfo.firstCharacterIndex + i];
  322. if (!cInfo.isVisible) continue; // Skip invisible characters.
  323. int vertexIndex = cInfo.vertexIndex;
  324. uiVertices[vertexIndex + 0].color = c;
  325. uiVertices[vertexIndex + 1].color = c;
  326. uiVertices[vertexIndex + 2].color = c;
  327. uiVertices[vertexIndex + 3].color = c;
  328. }
  329. m_TextMeshPro.canvasRenderer.SetVertices(uiVertices, uiVertices.Length);
  330. #endregion
  331. }
  332. */
  333. #endregion
  334. }
  335. public void OnPointerUp(PointerEventData eventData)
  336. {
  337. //Debug.Log("OnPointerUp()");
  338. }
  339. void RestoreCachedVertexAttributes(int index)
  340. {
  341. if (index == -1 || index > m_TextMeshPro.textInfo.characterCount - 1) return;
  342. // Get the index of the material / sub text object used by this character.
  343. int materialIndex = m_TextMeshPro.textInfo.characterInfo[index].materialReferenceIndex;
  344. // Get the index of the first vertex of the selected character.
  345. int vertexIndex = m_TextMeshPro.textInfo.characterInfo[index].vertexIndex;
  346. // Restore Vertices
  347. // Get a reference to the cached / original vertices.
  348. Vector3[] src_vertices = m_cachedMeshInfoVertexData[materialIndex].vertices;
  349. // Get a reference to the vertices that we need to replace.
  350. Vector3[] dst_vertices = m_TextMeshPro.textInfo.meshInfo[materialIndex].vertices;
  351. // Restore / Copy vertices from source to destination
  352. dst_vertices[vertexIndex + 0] = src_vertices[vertexIndex + 0];
  353. dst_vertices[vertexIndex + 1] = src_vertices[vertexIndex + 1];
  354. dst_vertices[vertexIndex + 2] = src_vertices[vertexIndex + 2];
  355. dst_vertices[vertexIndex + 3] = src_vertices[vertexIndex + 3];
  356. // Restore Vertex Colors
  357. // Get a reference to the vertex colors we need to replace.
  358. Color32[] dst_colors = m_TextMeshPro.textInfo.meshInfo[materialIndex].colors32;
  359. // Get a reference to the cached / original vertex colors.
  360. Color32[] src_colors = m_cachedMeshInfoVertexData[materialIndex].colors32;
  361. // Copy the vertex colors from source to destination.
  362. dst_colors[vertexIndex + 0] = src_colors[vertexIndex + 0];
  363. dst_colors[vertexIndex + 1] = src_colors[vertexIndex + 1];
  364. dst_colors[vertexIndex + 2] = src_colors[vertexIndex + 2];
  365. dst_colors[vertexIndex + 3] = src_colors[vertexIndex + 3];
  366. // Restore UV0S
  367. // UVS0
  368. Vector2[] src_uv0s = m_cachedMeshInfoVertexData[materialIndex].uvs0;
  369. Vector2[] dst_uv0s = m_TextMeshPro.textInfo.meshInfo[materialIndex].uvs0;
  370. dst_uv0s[vertexIndex + 0] = src_uv0s[vertexIndex + 0];
  371. dst_uv0s[vertexIndex + 1] = src_uv0s[vertexIndex + 1];
  372. dst_uv0s[vertexIndex + 2] = src_uv0s[vertexIndex + 2];
  373. dst_uv0s[vertexIndex + 3] = src_uv0s[vertexIndex + 3];
  374. // UVS2
  375. Vector2[] src_uv2s = m_cachedMeshInfoVertexData[materialIndex].uvs2;
  376. Vector2[] dst_uv2s = m_TextMeshPro.textInfo.meshInfo[materialIndex].uvs2;
  377. dst_uv2s[vertexIndex + 0] = src_uv2s[vertexIndex + 0];
  378. dst_uv2s[vertexIndex + 1] = src_uv2s[vertexIndex + 1];
  379. dst_uv2s[vertexIndex + 2] = src_uv2s[vertexIndex + 2];
  380. dst_uv2s[vertexIndex + 3] = src_uv2s[vertexIndex + 3];
  381. // Restore last vertex attribute as we swapped it as well
  382. int lastIndex = (src_vertices.Length / 4 - 1) * 4;
  383. // Vertices
  384. dst_vertices[lastIndex + 0] = src_vertices[lastIndex + 0];
  385. dst_vertices[lastIndex + 1] = src_vertices[lastIndex + 1];
  386. dst_vertices[lastIndex + 2] = src_vertices[lastIndex + 2];
  387. dst_vertices[lastIndex + 3] = src_vertices[lastIndex + 3];
  388. // Vertex Colors
  389. src_colors = m_cachedMeshInfoVertexData[materialIndex].colors32;
  390. dst_colors = m_TextMeshPro.textInfo.meshInfo[materialIndex].colors32;
  391. dst_colors[lastIndex + 0] = src_colors[lastIndex + 0];
  392. dst_colors[lastIndex + 1] = src_colors[lastIndex + 1];
  393. dst_colors[lastIndex + 2] = src_colors[lastIndex + 2];
  394. dst_colors[lastIndex + 3] = src_colors[lastIndex + 3];
  395. // UVS0
  396. src_uv0s = m_cachedMeshInfoVertexData[materialIndex].uvs0;
  397. dst_uv0s = m_TextMeshPro.textInfo.meshInfo[materialIndex].uvs0;
  398. dst_uv0s[lastIndex + 0] = src_uv0s[lastIndex + 0];
  399. dst_uv0s[lastIndex + 1] = src_uv0s[lastIndex + 1];
  400. dst_uv0s[lastIndex + 2] = src_uv0s[lastIndex + 2];
  401. dst_uv0s[lastIndex + 3] = src_uv0s[lastIndex + 3];
  402. // UVS2
  403. src_uv2s = m_cachedMeshInfoVertexData[materialIndex].uvs2;
  404. dst_uv2s = m_TextMeshPro.textInfo.meshInfo[materialIndex].uvs2;
  405. dst_uv2s[lastIndex + 0] = src_uv2s[lastIndex + 0];
  406. dst_uv2s[lastIndex + 1] = src_uv2s[lastIndex + 1];
  407. dst_uv2s[lastIndex + 2] = src_uv2s[lastIndex + 2];
  408. dst_uv2s[lastIndex + 3] = src_uv2s[lastIndex + 3];
  409. // Need to update the appropriate
  410. m_TextMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All);
  411. }
  412. }
  413. }