- Home /
Unity 2017 frame rate capped?
I'm trying to determine the frame rate of my game - I open a new project with nothing but the default 3d scene (Main Camera + Direction Light) and hit play - the frame rate in stats window bounces between 68 and 70 fps.
This script (which I want to use in order to see the fps on the actual Android device) says the frame rate is consistently @ 59 fps
using UnityEngine;
using System.Collections;
public class TestFPS : MonoBehaviour
{
private int FramesPerSec;
private float frequency = 1.0f;
private string fps;
void Start()
{
StartCoroutine(FPS());
}
private IEnumerator FPS()
{
for (;;)
{
// Capture frame-per-second
int lastFrameCount = Time.frameCount;
float lastTime = Time.realtimeSinceStartup;
yield return new WaitForSeconds(frequency);
float timeSpan = Time.realtimeSinceStartup - lastTime;
int frameCount = Time.frameCount - lastFrameCount;
// Display it
fps = string.Format("FPS: {0}", (frameCount / timeSpan));
}
}
void OnGUI()
{
GUI.Label(new Rect(Screen.width - 100, 10, 150, 20), fps);
}
}
a) I'm wondering why the fps is so low with nothing in the scene?
b) why are the frame rates off by so much?
c) anyone suggest another method for testing fps on android devices?
Thanks for any help
Answer by x4637x · Aug 01, 2017 at 04:42 AM
You might want to turn of V-Sync in unity, is locate in Edit -> Project Setting -> Quality, change V Sync Count to "Don't Sync".
Thanks, that worked. The script is way off compared to states menu, however, and vsync is enabled on android anyway so I can't see what the actual frame rate is on the device regardless. I was hoping to be able to closely monitor fps while developing on android to quickly catch issues, but it looks like ill find another way.. thanks tho, that worked in editor!
Thanks for your help, $$anonymous$$enyus777. All my questions were not answered
If you want to know more detail about your game performance , you could always check it in Unity's Profiler. Just need to enable "Development Build" and "Auto-connect Profiler" in Build Settings, and make sure your device and your unity machine are in the same network. Once you run your game on the device, Unity should let you chooses it under "Connected Player" in Profiler. From there you could easily tell how performance been taken by different modules.
Answer by mayur7garg · Nov 28, 2018 at 06:11 PM
a) The FPS is in the editor can be low because of many reasons -
Computer specifications aren't great. Having more RAM, better CPU and a larger GPU will greatly improve that.
That FPS is with the editor running which itself consumes a lot of computing resources and hence lowers the FPS. (You can take a Windows/Mac build of your project to see the improvement in FPS when the editor is not running.)
Graphical and Quality settings. (However their impact will be minimal on an almost empty project). Try tweaking those.
b) If you are talking about the difference in FPS in the editor and that of the Android build, that is because displays on most mobile devices have refresh rates capped at 60Hz (Limitation of mobile displays). So you cannot have an FPS of over 60 on any mobile device (except the Razor phone which is capped at 120Hz). 59 is probably the best you can get. (Your script won't even display 60 cause of minor minor fluctuations while refreshing. To see how close to 60 you can get, just try printing 1/Time.deltaTime
every frame.)
c) Your script is a good implementation of displaying FPS. If you wish, you can try downloading FPS assets from the store.
Your answer
Follow this Question
Related Questions
Problem with android on screen GUI 1 Answer
Motorola issues 0 Answers
Very Bad Performance on Android 3 Answers
Performance issues with touch/android build. 0 Answers
Is Screen.Orientation always portrait in Debug Mode? 0 Answers