2D Toolkit Forum

2D Toolkit => Support => Topic started by: ENAY on April 10, 2012, 10:58:23 am

Title: Aligned Text / Real world coordinate size of a TextMesh?
Post by: ENAY on April 10, 2012, 10:58:23 am
If there a way of returning how wide in Unity coordinates how big in width or height?

Basically a ".GetWidth()" function.

What I want to do is make centrally aligned text so I move the text along by half of the mesh width.
Title: Re: Aligned Text / Real world coordinate size of a TextMesh?
Post by: unikronsoftware on April 10, 2012, 11:13:41 am
You can either use the mesh bounds, or make tk2dTextMesh.GetMeshDimensionsForString() public and call that.

In the event that you just want to position this, and its not going to affect how the string is formatted, simply use the mesh bounds. Its much easier to work with. Otherwise, you can simply make that method public and use that to measure a string for you without actually changing the contents.
Title: Re: Aligned Text / Real world coordinate size of a TextMesh?
Post by: ENAY on April 11, 2012, 03:49:25 am
I was actually looking at bounds, but thought maybe that it was internally calculated within the mesh itself. Cheers for the tips, looks like I have some things I can experiment with.