Replace Text with coresponding 3D Models

So here is my idea but I am not really sure how to implement it. I want to develop a script that evaluates what the user types in a string into a public field or even the Text Mesh component. This script will run through each letter of what was typed and instantiate the corresponding 3D model. So in essence, I can create all the characters of the alphabet in 3D and export them into Unity. When I type into the text field and hit play…the script will display the 3D models of the characters.

Positioning, size and readability don’t matter so much here. I just wanted to know if it was possible and maybe some ideas on how to start it.

I am newbie when it comes to C#, but I figured out that you can use something like this to display when a textobject contains a certain string.

GetComponent<TextMesh>().text = test;

if (test.IndexOf("this") != -1)
        {
            Instantiate(textObj, transform.position, transform.rotation);
            Debug.Log("string contains 'this'");
        }

I know realistically, that I need to do some sort of Loop in order to check each character of the string and then match it to the corresponding 3D Model. Thoughts? Comments? Am I sort of on the right track?

Thanks for reading and for any help or suggestions you might have.

There are probably many ways to do this, but off the top:

Create an array of GameObjects, sized to 128. Drop your text object models (prefabs) into the slot corresponding to the ascii code in the array. Example: Element 65 would correspond to model ‘A’. (note you can make an Editor script to aid this process).

When running, access the string you are converting character-at-a-time with String. Untested:

var chars : GameObject[]; // assign these inspector or with Editor script

for (int i = 0; i < str.length; i++)
  Instantiate (chars[((int)str*)], new Vector3(i, 0, 0), Quaternion.identity);*