- Home /
Changing Text Mesh at Runtime
Is it possible to change the String of a Text Mesh (3DText) at runtime ? If not, I guess I have to use a GUIText Object and place it into 3D space. If so, can anyone point me in the right direction ?
Answer by Ashkan_gc · Jan 29, 2010 at 06:42 PM
there is a text property in the component that you can change. you should use GetComponent to get a reference to your textMesh and then change it's properties. also i should note that GUI in 3d space is not possible at this time. as inserted in the another answer take a look at this for more information.
Answer by ttpro1995 · Oct 08, 2015 at 10:42 AM
Here is C# script. Please attach it to your object with Text Mesh.
using UnityEngine;
using System.Collections;
public class TextController : MonoBehaviour {
private string displayText;
private TextMesh testMesh;
// Use this for initialization
void Start () {
display();
}
// Update is called once per frame
void Update () {
}
void display()
{
displayText = "meow meow meow";//get display text
testMesh = GetComponent<TextMesh>();//
testMesh.text = displayText;
}
}
Your answer
Follow this Question
Related Questions
Is Mesh Collider Optimal for GUI? 2 Answers
Need help: Instantiating prefab or use GUITexture? Or any alternative? 0 Answers
Is it possible to use DrawMesh inside an EditorWindow? 0 Answers
Draw a mesh in "Scene", and "Game" tab, before "Playing"? 1 Answer
How to replace this Gui text with text mesh please ? 1 Answer