textmesh pro text unity

Code Example - textmesh pro text unity

                
                        using TMPro;
//Declare variable of type text mesh pro text
TextMeshProUGUI TMPtext;
//Class variables
TMPText.text = "beans";
                    
                
 

unity textmeshpro

                        
                                using UnityEngine;
using TMPro;

public class quizManager : MonoBehaviour
{
    public TextMeshProUGUI text;
    // Start is called before the first frame update
    void Start()
    {
        text.text = "example";
    }
}
                            
                        
 

unity textmesh pro

                        
                                using UnityEngine;
using TMPro;

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

unity get textmesh pro component

                        
                                GetComponent<TMPro.TextMeshProUGUI>().text
                            
                        
 

how to reference text mesh pro unity

                        
                                using UnityEngine;
using TMPro;

public class Score : MonoBehaviour
{
    public TextMeshProUGUI text;
    public static int Score;

    // Use this for initialization
    void Start()
    {
        text = GetComponent<TextMeshProUGUI>();
    }

    // Update is called once per frame
    void Update()
    {
        text.text = NewScore.ToString();
    }
}