public static int renderFrameInterval ;

Description

Get or set the current frame rate interval. To restore rendering back to the value of Application.targetFrameRate or QualitySettings.vSyncCount set this to 0 or 1.

using UnityEngine;
using UnityEngine.Rendering;

// This example shows how to get and set the current frame rate interval and what you can do with that information. public class Example : MonoBehaviour { void Start() { QualitySettings.vSyncCount = 0; Application.targetFrameRate = 60; OnDemandRendering.renderFrameInterval = 6; }

void Update() { if (Input.GetMouseButton(0) || (Input.touchCount > 0)) { // If the mouse button or a finger is down render at 60 FPS (every frame). OnDemandRendering.renderFrameInterval = 1; } else { // If there isn't any input then we can go back to 10 FPS (every 6 frames). OnDemandRendering.renderFrameInterval = 6; }

// We've decided to lower the frame rate by increasing the frame interval. Perhaps in a pause menu. // There may be some other systems that we don't need at that time. if (OnDemandRendering.renderFrameInterval < 1) { // Disable physics Physics.autoSimulation = false;

// Disable other systems or turn down audio volume for example. } else { // If we are back to the normal framerate turn physics back on. Physics.autoSimulation = true; } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961