2D Toolkit Forum

2D Toolkit => Support => Topic started by: OnlineCop on February 20, 2012, 07:24:16 pm

Title: tk2dtextmesh gizmo off visually within Unity3d
Post by: OnlineCop on February 20, 2012, 07:24:16 pm
When I add a tk2dtextmesh to my scene, the gizmo (the thing that lets you move/rescale/rotate your objects) appears in different locations of Unity based upon the type of whitespace found in the text.

I currently have a small timer animation which should show the text "TIME LEFT".

(http://unikronsoftware.com/2dtoolkit/forum/index.php?action=dlattach;topic=89.0;attach=56)
(http://unikronsoftware.com/2dtoolkit/forum/index.php?action=dlattach;topic=89.0;attach=50)

When the words are separated with a space, the gizmo appears below the text (sometimes far below), and what appears to be centered to the average width of each of the space-separated words.

If I replace the space between the words with an underscore, the gizmo is centered (both horizontally and vertically) over the text as I would expect.

(http://unikronsoftware.com/2dtoolkit/forum/index.php?action=dlattach;topic=89.0;attach=52)
(http://unikronsoftware.com/2dtoolkit/forum/index.php?action=dlattach;topic=89.0;attach=54)

This only appears to be a visual (editor) anomaly, but I was wondering what I could do (edit one of the .cs files?) to correct this so I can use spaces between my words without it moving the gizmo around (screenshots and text settings attached, if it helps explain).
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: unikronsoftware on February 20, 2012, 09:43:32 pm
What is the gizmo mode set to? Is it on Pivot or center? This could also be because of your font - could you send me a the font to look at?
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: OnlineCop on February 20, 2012, 10:22:13 pm
The gizmo mode is set to center. Pivot (whether using a space or an underscore) appears to place the gizmo at the bottom-left corner of the mesh, and doesn't appear to move based on the whitespace between the words.

For the font, do I provide the .fnt file, the .prefab, or the .mat?
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: unikronsoftware on February 20, 2012, 10:54:31 pm
fnt and texture will do, thanks
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: unikronsoftware on February 20, 2012, 10:54:59 pm
could you email that to support at unikronsoftware dot com, please.
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: unikronsoftware on February 20, 2012, 11:18:22 pm
Solved:

The fnt file had a line for the space character:
char id=32 x=236 y=86 width=0 height=0 xoffset=-113 yoffset=147 xadvance=7 page=0 chnl=0 letter="space"

It was offsetting the origin of the character by that (-113,147) pixel units when there was no reason to do so. I've added some code to handle this case in the future - in any case, that error there can be fixed by manually editing the text file.
Title: Re: tk2dtextmesh gizmo off visually within Unity3d
Post by: OnlineCop on February 21, 2012, 12:46:38 am
As a follow-up: The fonts were generated using GlyphDesigner (http://glyphdesigner.71squared.com/ (http://glyphdesigner.71squared.com/)) version 1.5.2 (953). I'll let them know what's happened when importing it into Unity (I might as well just send them the URL to this forum discussion).

But I wanted to post this name in here in case any future searches turn up with the same kind of oddity.