So I posted this question earlier, but the mod closed it saying I should write my scripts in c# instead of JavaScript, which is NOT a solution.
Anyway,
So I’ve built a very simple prototype for a day/night system. The scene has a plane that is 8x8 as the ground, 3 little houses I made out of cubes, a tall skinny cube (just there to cast a shadow), and 2 short cubes to represent characters. I also have 2 text renderers set up, one shows the current time (to include seconds) and the other shows the date.
Then I have a handful of scripts that control flow of time and display of date/time.
I noticed that the longer my app runs in play mode, the lower the framerate drops. It starts around 200fps then over a matter of minutes hangs out around 2fps.
When I play with the profiler on, it seems to be the time.js script I have attached to one of the text renderers.
This is it’s code:
#pragma strict
function Updatetime()
{
while(true)
{
var today = System.DateTime.Now;
GetComponent.<TextMesh>().text = today.ToString("hh:mm" + " " + "tt");
yield WaitForSeconds(0.5f);
}
}
function Start()
{
Updatetime();
}
function Update () {
Updatetime();
}
Now again, this was closed before anyone had the chance to offer advice on the topic.
Is there a better way to write this? Or, does anyone know specifically what might be causing such a frame rate drop over a matter of minutes?
Thanks, community!