- Home /
Question by
manny003 · May 21, 2015 at 08:02 PM ·
javascriptuiperformancestringmemory
UI.Text: Lerping scores in Update -- excessive String allocation?
I know that Strings can be a tricky thing and that if we're not careful -- the GC could be working overtime.
In my game, I "animate" the score by lerping towards my desired value in the Update function and displaying the score on screen using the new UI tools:
scoreLabel : UI.Text;
function Update() {
blah
blah
if (lerpScore < actualScore) {
lerpScore++;
scoreLabel.text = String.Format("{0:D7}", lerpScore);
}
}
I'm displaying the score with leading zero, old school style. Can someone explain what's going on internally with UI.Text? Am I allocating String memory every frame? What's a better method?
Thanks, Manny
Comment