Z
Z
Zimaell2020-12-29 15:11:59
Unity
Zimaell, 2020-12-29 15:11:59

How to change text in text mesh?

Looked at the examples and made by analogy

public GameObject CountText;
void Start(){
  CountText = transform.Find("CountText").gameObject;
  TextMesh text;
  text = CountText.GetComponent<TextMesh>();
  text.text = "99";
  }

me in reply
MissingComponentException: There is no 'TextMesh' attached to the "CountText" game object, but a script is trying to access it.
You probably need to add a TextMesh to the game object "CountText". Or your script needs to check if the component is attached before using it.

this object is a child, but the parent finds it, since I can turn it on / off through the script, it remains only to take the mesh component, but somehow it doesn’t want to ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-12-29
@Zimaell

You have an object, but there is no component TextMeshon it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question