41 lines
577 B
C#
41 lines
577 B
C#
using UnityEngine;
|
|
|
|
public class FPSCapper : MonoBehaviour
|
|
{
|
|
[Range(60f, 240f)]
|
|
public int FramerateCap = 60;
|
|
|
|
public bool UnlockFPS;
|
|
|
|
[Tooltip("Set to true to change Framerate Cap during runtime.")]
|
|
public bool Reset;
|
|
|
|
private void Start()
|
|
{
|
|
if (UnlockFPS)
|
|
{
|
|
Application.targetFrameRate = 0;
|
|
}
|
|
else
|
|
{
|
|
Application.targetFrameRate = FramerateCap;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Reset)
|
|
{
|
|
if (UnlockFPS)
|
|
{
|
|
Application.targetFrameRate = 0;
|
|
}
|
|
else
|
|
{
|
|
Application.targetFrameRate = FramerateCap;
|
|
}
|
|
}
|
|
Reset = false;
|
|
}
|
|
}
|