xxxxxxxxxx
//needed in order to use Text Mesh Pro
using TMPro;
public class YourClass : MonoBehaviour
{
public TextMeshProUGUI InfoText;
public void Something() {
//Write to the text mesh pro element InfoText
InfoText.text = "Write whatever text you want here!";
}
}
xxxxxxxxxx
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();
}
}
xxxxxxxxxx
using TMPro;
// This adds the function to the code
public TextMeshProUGUI (The name of textmp(a));
// Always cap the line with ; ^^^
// If your getting a compile on line 3(example) and it has TextMeshProUGUI first check if
// you have (using TMPro;) if not that's a compile error and Second Check if the UGUI is
// spelled correctly because if you type UGIU thats a compile error also.
(The name of textmp(a)).text = (variable(b)).ToString("C2");
// in this instance the (.text) can stay the same with text mesh pro
This Piece of code can make a text box (TMP) display the variable
// a = The Text Mesh Pro Text Box you need linked with a variable
// b = The Variable Being linked with a