News, Help, Resources, and Conversation. A User Showcase of the Unity Game Engine.
How can I change the text from within a script? (I'm having the component on an empty game object, and not on a canvas)
You need using TMPro; at the beginning.
To change the text, use GetComponent<TextMeshProUGUI>() to get the component and then the SetText() method.
Do you know if you can change the text from an animation, I've had some issues with that, wherever I change it on the animation time line it applies it to the entire timeline.
Not sure if I'm understanding what you're saying. You can call methods from the timeline of an animation and change the text via script.
Thats how I thought it should work too, and does for almost all the fields I've tried. For example, I'm changing the gradient, the size, the transparency, the position, etc... but if I try to change the text its like it takes effect outside of the timeline and just changes the text globally as if it had no idea I was editing the timeline.
[your gameobject].GetComponent <TextMeshProUGUI> ().text = [new text];