- Home /
Is Update() NOT linked with graphics refresh rate?
var counter : float; var elapsed : float; var fps : float;
function Update() { elapsed = Time.time; counter++; fps = counter/elapsed; }
When running the above code in the editor, the Stats popout reported ~1600fps, while fps settled at roughly ~80. I always thought Update() was called once per frame? Or is graphics refresh independent of the code loop?
Answer by Peter G · Jan 13, 2011 at 11:05 AM
Everything is in one loop. The FPS display in the editor only displays FPS based on rendertimes so it is not an accurate representation of your games FPS. Rendering is only done once per frame.
If I put another, independent test in OnPostRender, I get different results for the two measurements, sometimes - especially on mobile devices - significantly different. Am I missing something here?
Answer by Andronikus · Jan 13, 2011 at 11:05 AM
Frames per second are not independent, they are inclusive of the code. The processor/GPU still have to calculate out the scene of which includes the Update Function and the code it contains. How quickly this calculation resolves per second is your frames per second in game.
Answer by Eric5h5 · Jan 13, 2011 at 11:20 AM
Use this for measuring framerate: http://www.unifycommunity.com/wiki/index.php?title=FramesPerSecond. Update is called once every frame.
Thanks for the link - ah, so my game ISN'T running at 1600fps? ;-)