Version: 2022.1

OnDemandRendering.renderFrameInterval

切换到手册
public static int renderFrameInterval ;

描述

获取或设置当前帧率间隔。若要将渲染恢复为 Application.targetFrameRateQualitySettings.vSyncCount 的值,请将此设置为 0 或 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