- Home /
Text Mesh not updating during run time?
I have a text mesh that is suppose to count down from 60 to 0 and it does that fine in the inspector during run time. But it doesn't change on the screen. It just shows "Time:" which is what I have it to say before I run the game and the script activates. So what I need to know is if my code is wrong or if you can't change a text like that? Btw its 2d Text Mesh. and here is some of my code that effects it.
var timeText = GetComponentInChildren(tk2dTextMesh);
timeText.text = "Time: " + gameTimeLeft.ToString();
if(gameTimeLeft > 0 && timeCounter <= Time.time)
{
gameTimeLeft--;
timeCounter = Time.time+1;
}
Answer by jp2222 · May 07, 2013 at 11:13 PM
Missing a timeText.commit(); ?
http://www.unikronsoftware.com/2dtoolkit/doc/tutorial/scripting_a_text_mesh.html
Answer by Maroku · Apr 18, 2013 at 09:56 AM
I created a 3DText in the scene and attached this script to it and it works for me...
var startTime :float = 60;
var updateTime : float = 1.0;
var timeTime : float = 0.0;
function Start()
{
timeTime = updateTime + Time.time;
}
function Update()
{
transform.GetComponent(TextMesh).text = startTime.ToString();
if(Time.time >= timeTime)
{
startTime--;
timeTime = updateTime + Time.time;
}
}
I tried putting a 3d text in there and it works. But it still doesn't on the 2d text mesh and im not sure why still?
Your answer
