Hello Guest

Author Topic: Text in a sprite collection not aligning correctly?  (Read 4865 times)

bluelotus

  • Newbie
  • *
  • Posts: 18
    • View Profile
Text in a sprite collection not aligning correctly?
« on: October 22, 2012, 11:24:13 am »
Hi guys,

Trying to get an xml based font exported from glyph designer into 2dtoolkit and running as a sprite collection.. .
It is visible but I had to scale it up by a factor of 100 - the dimensions of the text mesh objects match what the letters should look like but the texture is not aligned and it looks like abstract art.

Any ideas where I am going wrong with this?

Thanks,

Blue L.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Text in a sprite collection not aligning correctly?
« Reply #1 on: October 22, 2012, 11:29:23 am »
Can you send me the font, please to support@unikronsoftware.com

bluelotus

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Text in a sprite collection not aligning correctly?
« Reply #2 on: October 23, 2012, 10:38:59 am »
Have done,  :)

Cheers,

Blue L.

bluelotus

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Text in a sprite collection not aligning correctly?
« Reply #3 on: October 25, 2012, 01:15:52 am »
The mystery is solved and it was my settings!  :D
Still a noob at this stuff -

It turns out I had selected the original .png file for the texture map - And not the atlas created tex from the sprite atlas obj. Which is why the texture was misaligned.

I must have set this when I could not see the font at all before I scaled it up in size.

Its now working perfectly thanks for your help!

However, I am now having trouble accessing the text mesh -

Ive tried making the text mesh as the child of the OBJ where the code is being run, and also having it separate as its own object -

But I keep getting,
Does not exist in the current context

or

Type `UnityEngine.GameObject' does not contain a definition for `mytextobj' and no extension method ....

I think there is some confusion for me around variables, scope and syntax for getting and setting -

It is also hard to understand the code examples I have found as the term, "textmesh" is used and I am not sure if this is an instance name or a class name, or something else -

Here are the examples I have been experimenting with -

   var myTextMesh = (GetComponent(TextMesh) as TextMesh);
    myTextMesh.text = "Pls work";


//and from unity script reference -

public class example : MonoBehaviour {
    void Example() {
        GetComponent<TextMesh>().text = "Hello World";
    }
}

Any advice around how to get this up and running would be great -

Thanks,

Chris.

bluelotus

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Text in a sprite collection not aligning correctly?
« Reply #4 on: October 28, 2012, 03:09:41 am »
OK solved my problem -  ;D

Needed to be referencing tk2dTextMesh - and then commit to update.

this.GetComponent<tk2dTextMesh>().text = FramesPerSec.ToString();
this.GetComponent<tk2dTextMesh>().Commit();

So far so good!

BLue L.