how to change text of a textmeshpro unity code example
Example 1: unity change text color
GameObject.GetComponent<Text>().color = Color.black;
Example 2: change textmesh pro text
using UnityEngine;
using System.Collections;
using TMPro;
public class ExampleClass : MonoBehaviour
{
void Example()
{
TextMeshPro textmeshPro = GetComponent<TextMeshPro>();
textmeshPro.SetText("The first number is {0} and the 2nd is {1:2} and the 3rd is {3:0}.", 4, 6.345f, 3.5f);
}
}
Example 3: unity change tmp text from script
using UnityEngine.UI;
using TMPro;
void Update()
{
TextMeshPro lemonsss = GetComponent<TextMeshPro>();
}