使用Text(TMP)需要引用命名空间TMPro
using TMPro
获取Text(TMP)
GetComponent<TMP_Text>()
以下为使用例子
using UnityEngine;
using TMPro;
public class Test : MonoBehaviour {
private TMP_Text _testTMP;
private void Awake() {
_testTMP = GameObject.Find("TestTMP").GetComponent<TMP_Text>();
}
void Start() {
_testTMP.text = "This is a test sentence";
}
}