Using integer variables as strings?

Heya,
for the 2d platformer tutorial again, I’m working on a simple lives gauge. Is there a way to use an integer’s value as a string? I remember there being a way in BASIC, but that’s the only programming language I’m familiar with.

Here’s my code so far:

//Create a label in the top, right-hand corner that shows Lerpz's lives

var icon : Texture2D;
print (PlatformerController.lives);

function OnGUI () {
	GUI.Box(Rect (Screen.width - 120, 20, 100, 30), GUIContent(icon, "X", PlatformerController.lives)));
}

Instead of GUIContent(icon, "X", PlatformerController.lives)you can useGUIContent(icon, "X" + PlatformerController.lives)

“+” concatenates strings.

Another example:

"Hello " + name + ". You have " + lives + " lives left."

Alternately, you could use lives.ToString();

That doesn’t help if you insert a comma that shouldn’t be there. :slight_smile:

Rune

True…