How to disable and enable vsync

I’m embarrassed to ask, since I’ve been using Unity for 1000s of hours over many years, as this is such a basic thing but I’ve been looking into it a lot and can’t work out what is happening

But a user was complaining about my game that vsync was off (thus GPU was running 100%)
There is an option in my game to either enable or disable it

Application.targetFrameRate = -1;
QualitySettings.vSyncCount = (vsync_enabled ? 1 : 0);

now either setting vSyncCount to 0 or 1 changes nothing.
On my PC (nvidia card, windows) its the opposite, I can’t turn vsync off!
with a fullbuild why does vSyncCount = 0; not disable vsync (and yes I have search my code this is the only place vsync is set)

To make it clear this is talking about a fullbuild. i.e. not running in the editor.

Is it getting overruled by the graphics driver in a special settings or somewhere else?

cheers Zed

As you mentioned, you can force Vsync off or on via driver options, either globally or for a specific application (exe). It’s easy to verify whether this is the case or not, just open the Nvidia Control Panel.

The other thing you have to consider is GSync or similar monitor. This affects how Vsync gets interpreted. If Vsync is on and the monitor has Gsync the fps may still fluctuate between 20-120 Hz or similar but without the screen tearing.

1 Like

Thanks mate, It appears as if that was the case that VSync was being over ridden by the driver.

I assume its not possible to see if this is the case?
i.e I can somehow check if the graphic driver will ignore vSyncCount thus when the user tries to enable/disable vsync in my games settings then I can pop up a message that it won’t actually do anything as it’s being overridden by the driver

No.

Not only is that a waste of time - no game has ever done this. It’s not even your responsibility to do so. The user messed with the system so the user ought to know!

And most likely those sort of checks could start to fail with every new driver version, and you’d have to have a check for at least AMD, Nvidia, Intel and possibly others, and worst case for several individual models (mobile vs desktop) and driver types (WHQD, Game Ready, Studio, Windows default driver).

1 Like