Converting int into textmesh string (c#)
I'm trying to convert an int value into a string to use it in a textmesh but while the code runs and doesnt come up with any errors the text isn't changed. here is the code.
GameObject to = Instantiate (Resources.Load("textObj"),gameObject.transform.position,Quaternion.identity) as GameObject;
to.GetComponent<TextMesh> ().text = baseDam.ToString();
the text mesh still reads "hello world" rather than the baseDam value whats going wrong?
I just tried promoting the string to a variable like so
damString = baseDam.ToString ();
GameObject texo = Instantiate (Resources.Load("textObj"),gameObject.transform.position,Quaternion.identity) as GameObject;
texo.GetComponent<Text$$anonymous$$esh> ().text = damString;
but no luck the text remains the same "hello world" can anyone help?
Answer by the_megajoey · Jul 05, 2016 at 11:00 AM
False alarm sorry I was checking the wrong object the above code works fine!
Your answer
![](https://koobas.hobune.stream/wayback/20220612084139im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
C# .ToString Method Not executing 0 Answers
Identifying the Text on the block 1 Answer
(Solved) Changed Unity versions, now Text Mesh Pro has compile errors. How do I fix this?!?!? 1 Answer
Spawn random letters 0 Answers
Script updates prefab text 0 Answers