Search Unity

Question Only 60Hz FPS on Mac

Discussion in 'macOS' started by Raymond_XJTU, Aug 22, 2021.

  1. Raymond_XJTU

    Raymond_XJTU

    Joined:
    Jul 24, 2021
    Posts:
    3
    I create a simple 3D scene(with only one cube) on My MBP16' , the top FPS is only 60FPS, but the sample scene can reach 400FPS on my Win PC. Most important of all, the GPU of Mac is about 2x times better than my old PC.
    I tried many methods, such as closing the vsync, or use the code to control FPS. It worked when the Rate is set bellow 60Hz(such as 50Hz), but it doesn't work if I set the Rate higher than 60Hz(such as 120Hz). Can anyone help me?

    public float Rate = 120f;
    float currentFrameTime;

    void Start()
    {

    QualitySettings.vSyncCount = 0;
    Application.targetFrameRate = 300;
    currentFrameTime = Time.realtimeSinceStartup;
    StartCoroutine("WaitForNextFrame");
    }

    IEnumerator WaitForNextFrame()
    {
    while (true)
    {
    yield return new WaitForEndOfFrame();
    currentFrameTime += 1.0f / Rate;
    var t = Time.realtimeSinceStartup;
    var sleepTime = currentFrameTime - t - 0.01f;
    if (sleepTime > 0)
    Thread.Sleep((int)(sleepTime * 1000));
    while (t < currentFrameTime)
    t = Time.realtimeSinceStartup;
    }
    }
     
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    What happens if you put the monitor at 120hz and dont put any framerate target in unity?