- Home /
Question by
grangerave · Jun 21, 2013 at 07:27 PM ·
c#texttextmesh
How do I change text in a TextMesh of an instantiated object?
I'm trying to instantiate an empty object with a text mesh attached using a script, and then change the text to something specific. I have a prefab with a text mesh attached to it stored as a variable, and the script instantiates it, but the script does not compile.
Transform name = Instantiate(pickupNamePrefab,transform.position,transform.rotation) as Transform;
//pickupNamePrefab is an empty with a text mesh attached
name.GetComponent<TextMesh>().text = " hello ";
When i try to compile, unity gives me
error CS0029: Cannot implicitly convert type `UnityEngine.Transform' to 'string'
Has anyone had the same problem or know of an easier way to do it? Help would be much appreciated
Comment
Your answer
Follow this Question
Related Questions
i Have AN error when i create assets font editor 0 Answers
How can I get access default library in code 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Text along a curve 2 Answers