Please help. I have the following code to assign a new font type to a TextMesh, the font type is assigned to the TextMesh, but only blocks are appearing instead of the text. If still in Runtime I change to the default built in Arial, everything is ok. What can be the problem? As always, thank you in advance for any suggestion.
var tm : TextMesh = TheText.GetComponent(TextMesh);
tm.text = "Some string";
tm.font= Resources.Load("calibrili") as Font;
Also change the Material.
You can see this not in run-time, with manual changes. Sometimes changing just the font will accidentally look fine, and Ariel+no material usually works. But more often than not you get that same blockiness if you don’t create and use a proper Font Material (or using the wrong one produces shifted, rotated letter parts.)
Just came across this: was adding a TextMesh dynamically and all I got out was boxes–capital letters were bigger boxes, sure, but just boxes. As suggested above, the solution was adding the tagged line below:
TextMesh tm = obj.AddComponent<TextMesh>() as TextMesh;
tm.characterSize = 0.5f;
tm.text = "xXx";
tm.color = Color.green;
tm.anchor = TextAnchor.MiddleCenter;
tm.transform.position = new Vector3(0,0,4);
tm.font = GuiFont;
MeshRenderer rend = obj.GetComponentInChildren<MeshRenderer>();
rend.material = tm.font.material; /* ADDED THIS */