targetFrameRate
Specifies the target frame rate at which Unity tries to render your application.
Read time 4 minutesLast updated 4 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static int targetFrameRate { get; set; }
Remarks
Accepts an integer > 0, or special value -1 (default).
Desktop
- If QualitySettings.vSyncCount is set to , then
0chooses a target frame rate for the application. IfApplication.targetFrameRate, thenvSyncCount != 0is ignored.targetFrameRate - When and
QualitySettings.vSyncCount = 0, content is rendered unsynchronized as fast as possible.Application.targetFrameRate = -1 - It's recommended to use over
QualitySettings.vSyncCountbecauseApplication.targetFrameRateimplements a hardware-based synchronization mechanism, whereasvSyncCountis a software-based timing method and is subject to microstuttering.targetFrameRate - Setting and using
vSyncCount = 0will not produce a completely stutter-free output. Always usetargetFrameRatewhen smooth frame pacing is needed.vSyncCount > 0
Web
- If QualitySettings.vSyncCount is set to , then
0chooses a target frame rate for the application. IfApplication.targetFrameRate, thenvSyncCount != 0is ignored.targetFrameRate - When and
QualitySettings.vSyncCount = 0, content is rendered at the native display refresh rate.Application.targetFrameRate = -1 - It's recommended to use QualitySettings.vSyncCount over because
Application.targetFrameRateimplements a hardware-based synchronization mechanism, whereasvSyncCountis a software-based timing method and is subject to microstuttering.targetFrameRate - Setting and using
vSyncCount = 0will not produce a completely stutter-free output. Always usetargetFrameRatewhen smooth frame pacing is needed.vSyncCount > 0 - Rendering is always limited by the maximum refresh rate of the display. Setting and
vSyncCount = 0to an arbitrarily high value will not exceed the display's native refresh rate, even if the rendering workload is sufficiently low.targetFrameRate
Android
- Use to control the frame rate of your application. This is useful for capping your application's frame rate to make sure your application displays smoothly and consistently under heavy rendering workloads. You can reduce your application's frame rate to conserve battery life and avoid overheating on mobile devices.
targetFrameRate - When and
QualitySettings.vSyncCount = 0, content is rendered at a fixed 30 fps to conserve battery power, independent of the native refresh rate of the display.Application.targetFrameRate = -1are ignored.QualitySettings.vSyncCount > 0 - Rendering is always limited by the maximum refresh rate of the display. Setting and
vSyncCount = 0to an arbitrarily high value will not exceed the display's native refresh rate, even if the rendering workload is sufficiently low.targetFrameRate - To render at the native refresh rate of the display, set to the value from the Resolution.refreshRateRatio field of the Screen.currentResolution property.
Application.targetFrameRate - If the specified rate doesn't evenly divide the current refresh rate of the display, then the value of is rounded down to the nearest number that does. For example, when running on a 60 Hz Android display, and
Application.targetFrameRate, content is rendered at 20 fps as 20 is the highest number below 25 that divides 60 evenly.Application.targetFrameRate = 25
iOS
- Use to control the frame rate of your application. This is useful for capping your application's frame rate to make sure your application displays smoothly and consistently under heavy rendering workloads. You can also reduce your application's frame rate to conserve battery life and avoid overheating on mobile devices.
targetFrameRate - When and
QualitySettings.vSyncCount = 0, content is rendered at a fixed 30 fps to conserve battery power, independent of the native refresh rate of the display.Application.targetFrameRate = -1are ignored.QualitySettings.vSyncCount > 0 - Rendering is always limited by the maximum refresh rate of the display. Setting and
vSyncCount = 0to an arbitrarily high value will not exceed the display's native refresh rate, even if the rendering workload is sufficiently low.targetFrameRate - To render at the native refresh rate of the display, set to the integer representation of the screen's refresh rate. This can be retrieved from the value of the
Application.targetFrameRateproperty. For example,Screen.currentResolution.refreshRateRatio.Application.targetFrameRate = (int)Screen.currentResolution.refreshRateRatio.value; - The native refresh rate of the display is controlled by the Apple ProMotion feature. When ProMotion is disabled in the project (default for new projects), the native refresh rate is 60 Hz. When ProMotion is enabled, the native refresh rate is 120 Hz on the iOS displays that support ProMotion, 60 Hz otherwise.
- If the specified rate doesn't evenly divide the current refresh rate of the display, then the value of is rounded down to the nearest number that does.
Application.targetFrameRate
XR platforms
XR platforms ignore both QualitySettings.vSyncCount and . Instead, the XR SDK controls the frame rate.
Application.targetFrameRateUnity Editor
In the Editor, affects only the Game view. It has no effect on other Editor windows.
Application.targetFrameRateAdditional Resources: QualitySettings.vSyncCount, Screen.currentResolution.
Examples
using UnityEngine;public class Example : MonoBehaviour{ void Start() { // Limit framerate to cinematic 24fps. QualitySettings.vSyncCount = 0; // Set vSyncCount to 0 so that using .targetFrameRate is enabled. Application.targetFrameRate = 24; }}