private List <RectTransform> ChangeWordToChars(string word) { if (!commandPrefix.text.Contains(word)) { Debug.LogError($"\"{word}\" not found in string!"); return(null); } TMP_TextInfo textInfo = commandPrefix.textInfo; Debug.Log("First 3 chars of text info are: " + textInfo.characterInfo[0].character + textInfo.characterInfo[1].character + textInfo.characterInfo[2].character); List <RectTransform> charList = new List <RectTransform>(); string commandText = commandPrefix.text; int wordIndex = commandText.IndexOf(word); int charCount = textInfo.characterCount; Debug.Log($"cText: {commandText}, wIndex: {wordIndex}, cCount: {charCount}"); //The Y of the first letter, making sure every letter is on the right height TMP_CharacterInfo tempCInfo = textInfo.characterInfo[0]; float firstY = VectorExtensions.Center(commandPrefix.transform.TransformPoint(tempCInfo.topRight), commandPrefix.transform.TransformPoint(tempCInfo.bottomLeft)).y; for (int i = wordIndex; i < charCount; i++) { TMP_CharacterInfo cInfo = textInfo.characterInfo[i]; if (!cInfo.isVisible) { continue; } //Gets the center of the letter Vector3 bottomLeft = commandPrefix.transform.TransformPoint(cInfo.bottomLeft); Vector3 topRight = commandPrefix.transform.TransformPoint(cInfo.topRight); Vector3 center = VectorExtensions.Center(topRight, bottomLeft); center.y = firstY; //Spawn the characters TextMeshProUGUI obj = Instantiate(charPrefab, center, Quaternion.identity); string c = cInfo.character.ToString(); obj.name = c; obj.text = c; obj.transform.parent = commandPrefix.transform; obj.transform.localScale = Vector3.one; charList.Add((RectTransform)obj.transform); } commandPrefix.text = commandText.Remove(wordIndex); return(charList); }