Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseThe current estimated rate of rendering in frames per second rounded to the nearest integer.
This is an estimate and may not be achieved depending upon the application.
If QualitySettings.vSyncCount is greater than 0 it is calculated by:
FPS = Resolution.refreshRate / QualitySettings.vSyncCount / OnDemandRendering.renderFrameInterval
If QualitySettings.vSyncCount is 0 and Application.targetFrameRate is also greater than 0:
FPS = Application.targetFrameRate / OnDemandRendering.renderFrameInterval
Android, iOS and tvOS use 30 FPS as the default framerate when no other value has been specified. In that case 30 / OnDemandRendering.renderFrameInterval is returned. All other platforms return the value of Application.targetFrameRate.
using UnityEngine; using UnityEngine.Rendering; using System.Collections;
// This example shows how to use effectiveRenderFrameRate to ensure your application renders at a given frame rate regardless of // settings that could be changed by the user. Also demonstrates use of setting renderFrameInterval from a coroutine. public class Example : MonoBehaviour { void Start() { const int myTargetFrameRate = 10;
// Start off assuming that Application.targetFrameRate is 60 and QualitySettings.vSyncCount is 0 OnDemandRendering.renderFrameInterval = 6;
// Some applications may allow the user to modify the quality level. So we may not be able to rely on // the framerate always being a specific value. For this example we want the effective framerate to be 10. // If it is not then check the values and adjust the frame interval accordingly to achieve the framerate that we desire. if (OnDemandRendering.effectiveRenderFrameRate != 10) { if (QualitySettings.vSyncCount > 0) { OnDemandRendering.renderFrameInterval = (Screen.currentResolution.refreshRate / QualitySettings.vSyncCount / myTargetFrameRate); } else { OnDemandRendering.renderFrameInterval = (Application.targetFrameRate / myTargetFrameRate); } }
StartCoroutine(SlowRenderingFor5Seconds()); }
IEnumerator SlowRenderingFor5Seconds() { // After 5 seconds go back to rendering every frame yield return new WaitForSeconds(5); OnDemandRendering.renderFrameInterval = 1; }
void Update() { // For 5 seconds this will report that the effective framerate is 10. Afterward it will log what the framerate is given the current // quality and target framerate settings. Debug.Log("FrameRate: " + OnDemandRendering.effectiveRenderFrameRate); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.