fix: vsync toggle

This commit is contained in:
anavoi 2025-07-13 12:09:32 +02:00
commit 2619d05374

View file

@ -25,7 +25,6 @@ public class GBSUGui : MonoBehaviour
string serverip = null; string serverip = null;
int serverport = 5999; int serverport = 5999;
string currentmap; string currentmap;
int vsync_switch;
bool hosting = false; bool hosting = false;
private void Start() private void Start()
{ {
@ -37,8 +36,6 @@ public class GBSUGui : MonoBehaviour
{ {
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", true), out serverport); int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", true), out serverport);
} }
vsync_switch = QualitySettings.vSyncCount;
} }
private void Update() private void Update()
{ {
@ -159,16 +156,14 @@ Make sure to download a file from the examples given and rename it to config.jso
} }
if (GUI.Button(new Rect(20f, 330f, 170f, 30f), "Toggle VSync")) if (GUI.Button(new Rect(20f, 330f, 170f, 30f), "Toggle VSync"))
{ {
if (vsync_switch == 0) if (QualitySettings.vSyncCount == 0)
{ {
vsync_switch = 1; QualitySettings.vSyncCount = 1;
} }
else else
{ {
vsync_switch = 0; QualitySettings.vSyncCount = 0;
} }
QualitySettings.vSyncCount = vsync_switch;
} }
GUI.Label(new Rect(20f, 365f, 365f, 400f), $@" GUI.Label(new Rect(20f, 365f, 365f, 400f), $@"