- Home /
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:
The top being what I have, the bottom what I'm trying to get. Can anyone help me with this?
Answer by gheeler · Apr 12, 2013 at 11:56 AM
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[i].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