2D Toolkit Forum

2D Toolkit => Support => Topic started by: etoreo on January 30, 2014, 09:37:10 am

Title: addComponent<TextMesh>() doesn't render text
Post 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?
Title: Re: addComponent<TextMesh>() doesn't render text
Post by: unikronsoftware on January 30, 2014, 11:02:43 am
After adding the component, do you assign the font, text & Commit()?
Title: Re: addComponent<TextMesh>() doesn't render text
Post by: etoreo on January 30, 2014, 05:46:00 pm
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!
Title: Re: addComponent<TextMesh>() doesn't render text
Post by: unikronsoftware on January 30, 2014, 10:35:05 pm
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.
Title: Re: addComponent<TextMesh>() doesn't render text
Post by: etoreo on January 30, 2014, 10:45:33 pm
Thanks for the tips, I am sure this will get me where I need to go.
Title: Re: addComponent<TextMesh>() doesn't render text
Post by: scott on June 23, 2014, 08:43:03 am
Just encase anybody comes across this same issue, setting the font solved this issue for me - just as the original poster believed it would.