unity textmesh por set text code example

Example 1: unity textmesh pro

using UnityEngine;
using TMPro;

public class UiManager : MonoBehaviour
{
    [SerializeField]
    private TextMeshProUGUI TMPtext;
}

Example 2: how to edit text mesh pro text

using UnityEngine;
using System.Collections;
using TMPro;

public class ExampleClass : MonoBehaviour
{
	public TextMeshProUGUI textDisplay;
    
    void Example()
    {
        textDisplay.text = "Example Text"      
    }
}

Example 3: unity set text value

//Because the Text variable is public, 
//you will have to drag the Text box object onto the script in unity.
//So unity knows what text box to apply the script to.

public Text myText;
myText.text = "Enter the text value here!";

By: Barry Cox

Example 4: 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);
        // The text displayed will be:
        // The first number is 4 and the 2nd is 6.35 and the 3rd is 4.
    }
}

Example 5: unity change tmp text from script

using UnityEngine.UI;
using TMPro;

void Update()
{
    TextMeshPro lemonsss = GetComponent<TextMeshPro>();
}