2D Toolkit Forum
2D Toolkit => Support => Topic started by: etoreo on January 30, 2014, 09:37:10 am
-
I am dynamically creating a Game Object and calling addComponent<tk2dTextMesh>() on it.... but it doesn't draw. Inspecting it there doesn't seem to be a MeshFilter on the object - and when I manually change any value on the tk2dTextMesh object, the MeshFilter populates and the text is drawn. I have called Commit() on the tk2dTextMesh object after creating it and it still won't draw.
Any advice?
-
After adding the component, do you assign the font, text & Commit()?
-
The font is probably my problem, thanks. How can I get a font dynamically in my code? I don't see a directory of available fonts.
On a related note, how might I show an tk2dFont selector in a custom Unity Editor Window? I need something to the tune of EditorGUILayout.ObjectField so I can create my text from a wizard I am making.
Thanks a bunch!
-
You'll have to get fonts at runtime using Resources.Load. Its just the font data object that needs to be in resources for this to work.
The code that draws the font selector is in tk2dTextMeshEditor.cs, OnInspectorGUI. It performs lots of little checks to make sure assets are sensible.
-
Thanks for the tips, I am sure this will get me where I need to go.
-
Just encase anybody comes across this same issue, setting the font solved this issue for me - just as the original poster believed it would.