3D Text

I’m trying to create a 3D Text GameObject form script.
I added a font taht works, and I’m doing something like this:

GameObject Test = new GameObject();
TextMesh TestText = (TextMesh)Test.AddComponent("TextMesh");
TestText.font = (Font)Resources.Load("FontName",typeof(Font));
Test.AddComponent("MeshRenderer");

What did I do wrong?

Stupid question maybe… did you assign some text to the TextMesh’s “.text” property?

EDIT: you may also want to provide a proper font name (unless you have a font called “FontName”)

EDITx2: Since you’re using C#, you may as well use the typesafe generic versions of AddComponent:
TextMesh TestText = Test.AddComponent();

No changes with generic functions…

There wouldn’t be any changes with the generics; it would have just been a nice way of writing it. What about my other two suggestions?

I get the font on the TextMesh component with my code, but the characters are not drawn correctly.
If i change the font from editor ,to None and back to Gabriola, it works.
I’m begining to think that this is Unity3 bug.
p.s.
Yes, I know that…
I’m actually using a font called Gabriola. (FontName is just for example)
And yes, of course I added text to .text string.

It’s not a bug; you need to set up the material correctly.

–Eric

I did…thanks =)