3D Text Question

Here’s a part of the code I’m having trouble with. I want to update 3D text in the scene from a js attached to another object in the same scene.

the 3D text object is called “LEDCredits”

I’m converting an int to a string, then assigning that string to the TextMesh.

I know it’s converting to a string properly, but I can’t figure out what I’ve done wrong to get this error.

However, I keep getting a ‘text’ is not a member of UnityEngine.Component error.

I got this code from http://forum.unity3d.com/viewtopic.php?t=26474

Any help would really be appreciated.

Thanks!

var newtext: String;
var amount: int;

amount = InV.credit[InV.sm];
newtext = amount.ToString();

print("game credit = " + newtext);

var abc = GameObject.Find("LEDCredits");
abc.GetComponent(TextMesh).text = newtext;

GetComponent only returns a Component, which indeed doesn’t have a .text member.

(abc.GetComponent(TextMesh) as TextMesh).text = newtext;

–Eric

Thank you!

I tried that didn’t earlier, and it didn’t work then, but that may have been typos on my part. It’s working perfectly now.