Created
May 1, 2022 23:12
-
-
Save rrazgriz/a28bb983eb4169e012340b6f1e5bf39f to your computer and use it in GitHub Desktop.
Script to Limit framerate of unity editor, add to any GameObject to use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on LLeaLoo's script | |
#if UNITY_EDITOR | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
public class FramerateLimiter : MonoBehaviour | |
{ | |
public int targetFrameRate = 30; | |
} | |
[CustomEditor(typeof(FramerateLimiter), true)] | |
public class FramerateLimiterEditor : Editor | |
{ | |
private FramerateLimiter my; | |
public override void OnInspectorGUI() | |
{ | |
my = (FramerateLimiter) target; | |
this.DrawDefaultInspector(); | |
GUILayout.Label("Current Target Framerate: " + Application.targetFrameRate.ToString()); | |
if (GUILayout.Button("Update Target")){ SetTargetFramerate(); } | |
} | |
void SetTargetFramerate() | |
{ | |
my = (FramerateLimiter) target; | |
QualitySettings.vSyncCount = 0; // VSync must be disabled | |
Application.targetFrameRate = my.targetFrameRate; // Use -1 to set back to default | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment