📅  最后修改于: 2022-03-11 14:55:09.234000             🧑  作者: Mango
9. Why can't I get the text component via GetComponent()?
You can, but there are actually two different types of TextMeshPro
components. Non-UI text components have the TextMeshPro type, as expected
which can be access using GetComponent(). The UI text components
have the TextMeshProUGUI type. You can get those via
GetComponent().
Both TextMesh Pro components inherit from a base class which is
TMP_Text where you can also get a reference to either types of TextMesh Pro
components by using GetComponent(). To access these components in
your scripts you will also need to include the "using TMPro;" namespace.
From https://forum.unity.com/threads/how-to-create-object-reference-to-text-mesh-pro-object.505796/