Converting GUIText to 3D objects

I have a simple scoring system, that works just fine in terms of coding. I’m using a GUIText to display my score. What I want to do, is replace my digits with custom 3D number objects (that I will make in 3DS Max), maybe add some animation in transitions for each digit when switching from one number to the next etc. How can I do that?

I suppose it’s somewhat similar to using sprites to replace digits in counters in 2D games, but I can’t find any complete tutorial about that either.

For a somewhat crude technique, you can use an array of meshes for the digits 0-9, plus an array of GameObjects, and convert each digit in the score to the appropriate mesh. This assumes the number meshes are approximately 1 unit in size:

var numberMeshes : Mesh[];
var digits = 6;
var numberMaterial : Material;
private var numberObjects : GameObject[];
private var formatString = "";

function Start () {
	numberObjects = new GameObject[digits];
	for (var i = 0; i < digits; i++) {
		numberObjects *= new GameObject("Number object " + i, MeshFilter, MeshRenderer);*

_ numberObjects*.transform.position = Vector3(i, 0, 0);_
_ numberObjects.renderer.sharedMaterial = numberMaterial;
formatString += “0”;
}
UpdateScore (0);
}*_

function UpdateScore (score : int) {
* var scoreString = score.ToString(formatString);*
* for (var i = 0; i < digits; i++) {*
_ var digit : int = scoreString*;
numberObjects.GetComponent(MeshFilter).mesh = numberMeshes[digit - 48];
}
}
Then you’d call the UpdateScore function when the score changes. You’d also want to make sure the score doesn’t exceed the number of digits allocated. As I mentioned this is kind of crude; it’s just fixed width and can’t do stuff like proportional fonts. For something more sophisticated I’d suggest [FlyingText3D][1], which would make it pretty trivial to do fancier stuff by using the UpdateObject function. You’d have to do some extra coding if you want animation though.
[1]: http://www.starscenesoftware.com/flyingtext3d.html*_