Text Mesh

I attached a text mesh to one of my gameobjects. Now I need to change its text content, but I don’t know how to access its properties. I tried this,

MyGameObj.TextMesh.text = “hello”;

but it doesn’t seem to work. So what am I supposed to do to change the text content?

Use GetComponent. Normally this is what you’d use anyway, and it’s what happens behind the scenes, but some things like transform, guiText, etc. have shortcuts that do GetComponent for you.

–Eric

Yep. it works. Thank so much, Eric. :lol:

TextMesh txm = (TextMesh)go.GetComponent<TextMesh>();
txm.text = "Changed";