I have the following script which is attached to a 3D Text object, but the text never gets updated. I call this function from another script that's why i have it as static. I have put in debug statements before and after the text line below and confirmed that it does get executed, however the 3D Text object doesn't show the value of InitBlocks.timetobreakallBoards in the 3D Text object. What am I doing wrong? thanks
static function PresentTime () {
text = "Time: " + InitBlocks.timetobreakallBoards;
}
nvm, used the following to set a reference to the component and then a .text to access the text of the 3D Text. I also had to move this code back to another script that was attached to the original object. If I had this code in a script that was attached to the 3D Text object then it didn't work.
var tm = GameObject.Find("3DTextObject");
(tm.GetComponent(TextMesh) as TextMesh).text = "Time: " + InitBlocks.timetobreakallBoards;
Here, not tested though it should work
var textMesh:TextMesh;
function Start(){
textMesh = gameObject.GetComponent(TextMesh);
}
static function PresentTime () {
text = "Time: " + InitBlocks.timetobreakallBoards;
textMesh.text = text.ToString();
}