Fixed text spacing

Hi there! I’ve had a little bit of a run-in with some interface problem. I have a label in which I want the characters (in this case numbers) to have a fixed offset to each other. I’m trying to get it neat and clean instead of parsing every character to a different variable or something. This is what I’m trying to accomplish:

9987-8472-ui_levelselect_window1.jpg

The top being what I have, the bottom what I’m trying to get.
Can anyone help me with this?

1 Answer

1

you could do it easily enough by splitting them…

char[] chars = yourString.ToCharArray();
    Rect r = new Rect(0, 0, 20, 20);
    for (int i = 0; i < chars.Length; i++)
    {
        GUI.Label(r, chars*.ToString());*

r.x += 20;
}
may be a better way though. certain fonts i think use equal space for each character

Yeah I'd prefer another way, because this way makes extra interface elements and isn't thát performance balanced.

then best bet might be a certain font.. dont know if its to do with the formatting or the actual font that makes some equal character spacing

Have you read this http://forum.unity3d.com/threads/12723-Font-Line-spacing-amp-Kerning-in-GUI-system?