Application.targetFrameRate doesn't work in the Editor?

I seem to get wildly fluctuating frame-rates in the editor (200-500) and this results in very jerky motion. This happens even when I set Application.targetFrameRate to 60 and QualitySettings.vSyncCount to 1.

If I make an actual windows build, these settings take and everything is nice and smooth. So, is there a way to make targetFrameRate work in the editor?

Right now iterating on controls and motion in the editor is extremely frustrating.

If you're getting jerky motion, maybe you're putting your movement code in Update() instead of FixedUpdate()?

You're supposed to put movement in Update. FixedUpdate is only for physics, and will result in jerky movement if you put code in there (unless the physics framerate exceeds the screen framerate).

Eric's answer should explain Application.targetFrameRate. As for QualitySettings.vSyncCount, beware that Unity, as a client application, cannot overrule driver settings. VSync can be controlled externally in your driver control software. Check the setting there, too. If you have an NVidia card, its name is "NVidia Control Panel". I think it's called "Catalyst Control Center" for ATI cards. It should ideally be set to use Application Settings, so that client apps like Unity get to define their own.

1 Answer

1

As the docs say, targetFrameRate is ignored in the editor. You can use vsync (which should work—it does here). If you’re looking at the stats window, that’s how long it takes to draw the graphics, which isn’t necessarily the actual fps. You can use an fps counter script to see the real fps if necessary.

Yeah, I made an FPS counter script using System.Diagnostics.Stopwatch to check how many times Update gets called in a frame. I'm getting wildly varying frame-rates even with v-sync enabled.

Update is always called once per frame, by definition.

Use this: http://wiki.unity3d.com/index.php?title=FramesPerSecond That way you have a readout of the average fps over the previous half-second, so it doesn't vary every frame.