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?
Eric5h5
September 23, 2010, 2:14pm
2
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
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";