Closed Cloetta closed 6 months ago
Related : https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html https://docs.unity3d.com/ScriptReference/QualitySettings-vSyncCount.html
On all other platforms, Unity ignores the value of targetFrameRate if you set vSyncCount.
An option to also set the framerate would also be a nice thing if we can disable the vsync or a single option "targetFrameRate that do both like 0=vsync,, -1 unlimited (not sure if possible), otherwise set target frame rate to x fps).
So I believe that when you set Application.targetFrameRate
to -1
it uses the screen refresh rate but I can grab that at runtime anyway just in-case. Setting it to 0
uncaps the framerate (when VSync is off obviously).
It's kind of annoying because, say you wanted VSync on but the framerate capped to 60 you would have to use vSyncCount=1
on a 60Hz display, 2 on a 120Hz display etc etc. You effectively can't set an arbitrary framerate cap when VSync is enabled.
So with that, I'll add a VSync toggle but I won't be exposing Application.targetFrameRate
since it behaves differently when VSync is engaged. I think having both would just confuse people. I'd highly recommend setting a framerate cap with tools like RTSS/Special K/your GPU driver control panel. They'll produce better framepaced results than unity's framerate limiter anyway and they work just fine with VSync.
Edit: Something like this:
// Set vsync/target framerate
[HarmonyPatch(typeof(DisplaySetting), nameof(DisplaySetting.UpdateFrameRate))]
[HarmonyPostfix]
public static void SetVSync()
{
if (bVsync.Value)
{
QualitySettings.vSyncCount = 1;
}
// Uncap framerate when vsync is disabled.
Application.targetFrameRate = 0;
}
Added in v0.9.3.
Could it be possible to add a VSYNC toggle option to to remove the 60 fps lock?
Thank you for your service! 😄