Question by
OttoClausen · Aug 22, 2016 at 07:53 PM ·
optimizationstringmemorytostringallocation
Alternative to using .toString ?
I am using this line of code percentageCount.text = percentage.ToString("F1") + " %";
in my game to display how far the player has made it into the level. The function containing that line of code is called 20 times a second. However from looking at the profiler I can see that this function is allocating a bit of memory every time it is called which is obviously not good at all.
So my question is - how can I do something similar to this but without allocating memory?
Comment
A quick google search resulted in:
Also think about if you really NEED to update this 20 times per second.