You seem a bit confused about the use of TMP
1
If you set the TMP in the inspector as public you can simply
public TMP_text text;
And then simply drag the text inside the inspector and simply:
text.text = "Text displayed";
2
If you don't create a public variable but a private, you can:
private TMP_text text;
And then, if you script is in the text object you can:
text = this.gameObject.GetCOmponent<TextMeshPro>();
And
text.text = "Your text";
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…