Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float goalFPS = 30;
- private float millisecondsToWait;
- // Update is called once per frame
- void Update () {
- float overflow = 1.0f/goalFPS - Time.deltaTime;
- if (overflow > 0.0f)
- millisecondsToWait ++;
- else
- millisecondsToWait --;
- Thread.Sleep((int)Mathf.Clamp(millisecondsToWait, 0.0f, 1.0f/goalFPS * 1000.0f)); // clamp for sanity
- if (SystemInfo.graphicsDeviceID == 0)
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement