Generating words from Prefab alphabets at runtime from string variables

Hi,

How efficient it is to generate words from prefabs of alphabet mesh from A to Z depending on a string variable at runtime? Is it even possible? I want to create a table of high score with top 5 high scores. The text is displayed on a wooden plank like its embossed in it.

Any idea?

Thanks

How about just using a font? Then use GUIText (not OnGUI, because OnGUI can only use 1-color TTF fonts, not bitmap fonts.)

–Eric

Actually i want to hide the text which is revealed by a sliding door. The text is on a plank behind a sliding door. The player opens the door and as he does it, the text is revealed gradually. I tried using GUIText but its always displayed on top of everything. U cannot hide it or i dont know how to do it. Can u tell me if its possible or not?

Thanks

Maybe TextMesh then?

It behaves similar to GUIText, that is its always displayed on top of everything.

Try this shader on the door. That should resolve it.

http://www.unifycommunity.com/wiki/index.php?title=3DText

Thanks :smile: that did the trick. Can u please tell me how to add custom font. I downloaded one font(font is called The Great Escape). But when i select it all i see is white squares instead of text. Don’t know how to solve this problem. I applied it to 3d Text

here you go, just modify the Debug statement with your mesh assignement !

public class Generator : MonoBehaviour {

	public string word;
	public char[] convertedW;

	void Start () 
{
		word = "TEST"; 
		convertedW=word.ToCharArray();
	foreach (char letter in convertedW)
		{
		if((letter=='A')||(letter=='a'))
				Debug.Log(letter);
		if((letter=='B')||(letter=='b'))
				Debug.Log(letter);
		if((letter=='C')||(letter=='c'))
				Debug.Log(letter);
		if((letter=='D')||(letter=='d'))
				Debug.Log(letter);
		if((letter=='E')||(letter=='e'))
				Debug.Log(letter);
		if((letter=='F')||(letter=='f'))
				Debug.Log(letter);
		if((letter=='G')||(letter=='g'))
				Debug.Log(letter);
		if((letter=='H')||(letter=='h'))
				Debug.Log(letter);
		if((letter=='I')||(letter=='i'))
				Debug.Log(letter);
		if((letter=='J')||(letter=='j'))
				Debug.Log(letter);
		if((letter=='K')||(letter=='k'))
				Debug.Log(letter);
		if((letter=='L')||(letter=='l'))
				Debug.Log(letter);
		if((letter=='M')||(letter=='m'))
				Debug.Log(letter);
		if((letter=='N')||(letter=='n'))
				Debug.Log(letter);
		if((letter=='O')||(letter=='o'))
				Debug.Log(letter);
		if((letter=='P')||(letter=='p'))
				Debug.Log(letter);
		if((letter=='Q')||(letter=='q'))
				Debug.Log(letter);
		if((letter=='R')||(letter=='r'))
				Debug.Log(letter);
		if((letter=='S')||(letter=='s'))
				Debug.Log(letter);
		if((letter=='T')||(letter=='t'))
				Debug.Log(letter);
		if((letter=='U')||(letter=='u'))
				Debug.Log(letter);
		if((letter=='V')||(letter=='v'))
				Debug.Log(letter);
		if((letter=='W')||(letter=='w'))
				Debug.Log(letter);
		if((letter=='X')||(letter=='x'))
				Debug.Log(letter);
		if((letter=='Y')||(letter=='y'))
				Debug.Log(letter);
		if((letter=='Z')||(letter=='z'))
				Debug.Log(letter);
		}
	}
}

If you’re going to do something along these lines, you could easily convert the ASCII value of each character into an array index to access the proper mesh. That would result in much less code…

@ razormax:
Apply the font material (that is generated at importing the font) to the 3d text Object.
next step is to choose the font inside of the Text mesh under the property font.

If both are matching , it works.
if your text looks pixulated increase the font size.