Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Assets/Scripts/Graphics/TargetFrameRate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
using TMPro;

public class TargetFrameRate : MonoBehaviour {

void Awake () {
// Its a dead simple app. There's no need for 120 fps
// By default the vSyncCount is 2 (1/2 of max fps, ex. 120/2 = 60)

QualitySettings.vSyncCount = PlayerPrefs.GetInt("vSyncRate", 2);
Application.targetFrameRate = PlayerPrefs.GetInt("fpsTarget", 0);
// Its a dead simple app. There's no need for 120 fps
// By default the vSyncCount is 2 (1/2 of max fps, ex. 120/2 = 60)

QualitySettings.vSyncCount = PlayerPrefs.GetInt("vSyncRate", 2);
// fpsTarget is saved as a dropdown value, e.g. 3 for 30fps
Application.targetFrameRate = PlayerPrefs.GetInt("fpsTarget", 0) * 10;
}
}
32 changes: 7 additions & 25 deletions Assets/Scripts/UI/MainMenu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TMPro;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
Expand All @@ -24,38 +24,20 @@ void Awake() {

public void SetVSyncRatio(System.Int32 value)
{
// Clear fpsTarget
PlayerPrefs.SetInt("fpsTarget", 0);
fpsTarget.value = 0;
Application.targetFrameRate = -1;

if (value == 0)
{
SetFpsTarget(3);
}

PlayerPrefs.SetInt("vSyncRate", value);
vSyncRate.value = value;

QualitySettings.vSyncCount = value;

if (value != 0)
fpsTarget.value = 0;
}

public void SetFpsTarget(System.Int32 value)
{
// Clear vSync Count
PlayerPrefs.SetInt("vSyncRate", 0);
vSyncRate.value = 0;
QualitySettings.vSyncCount = 0;

if (value == 0)
{
SetVSyncRatio(2);
}

PlayerPrefs.SetInt("fpsTarget", value);
fpsTarget.value = value;

Application.targetFrameRate = value != 0 ? value * 10 : -1;

if (value != 0)
vSyncRate.value = 0;
}

void LateUpdate() {
Expand Down