How to draw 3D text from code

Hey guys,

I was wondering, how can you draw 3D text from code???

Thanks

-Grady

Use a TextMesh. There is also a script reference, which should definitely help you to create the text you are looking for.

Update
To create this in code, you can just add a component to your empty GameObject.

//somewhere in some manager object
function Awake()
{
    var theText = new GameObject();
    
    var textMesh = theText.AddComponent("TextMesh");
    var meshRenderer = theText.AddComponent("MeshRenderer");

    // do some settings here that are needed in the component
    // set the text
    textMesh.text = "Hello World!";
}

It depends if you need to set a font or not, because I don’t know if there is a default one. Please check that in your Hierarchy.

You can also do this:

var TEXT : Textmesh; // Drag your 3d text here in the inspector.

function Update ()
{
TEXT.text = "I just answered your question! I hope this helps";
}

Done. :slight_smile:

Where Do You Go

You can generate 3D text from code in many ways .One of this is, you first create a prefab of the characters , give it as an input to the script and then generate 3D text from script by instantiating gameobjects.

I found this YouTube video helpful How to Make 3D Text in Unity ||(100% Working) - YouTube