返回介绍

Time.captureFramerate 采集帧速率

发布于 2019-12-18 15:38:40 字数 2978 浏览 1215 评论 0 收藏 0

JavaScript => public static var captureFramerate: int;
C# => public static int captureFramerate;

Description 描述

Slows game playback time to allow screenshots to be saved between frames.

减慢游戏播放时间以允许在帧之间保存屏幕图像。

If this property has a non-zero value then frame update will occur at an interval of (1.0 / captureFramerate) regardless of real time and the time required to render a frame. This is useful if you want to capture a movie where you need a constant frame rate and leave enough time between frames to save screen images.

如果这个属性是非0的值,那么帧更新将发生在不管实际时间和渲染一帧所需时间的间隔(1.0 / captureFramerate)。这用于如果你想采集的影片需要固定的帧速率,帧之间留足够的时间来保存屏幕图像。

JavaScript:

// Capture frames as a screenshot sequence. Images are
// stored as PNG files in a folder - these can be combined into
// a movie using image utility software (eg, QuickTime Pro).
 
// The folder to contain our screenshots.
// If the folder exists we will append numbers to create an empty folder.
var folder = "ScreenshotFolder";
var frameRate = 25;
 
 
function Start () {
    // Set the playback framerate (real time will not relate to game time after this).
    Time.captureFramerate = frameRate;
 
    // Create the folder
    System.IO.Directory.CreateDirectory(folder);
}
 
function Update () {
    // Append filename to folder name (format is '0005 shot.png"')
    var name = String.Format("{0}/{1:D04} shot.png", folder, Time.frameCount );
 
    // Capture the screenshot to the specified file.
    Application.CaptureScreenshot(name);
}

C#:

using UnityEngine;
using System.Collections;
 
// Capture frames as a screenshot sequence. Images are
// stored as PNG files in a folder - these can be combined into
// a movie using image utility software (eg, QuickTime Pro).
 
public class ExampleClass : MonoBehaviour {
	// The folder to contain our screenshots.
	// If the folder exists we will append numbers to create an empty folder.
    public string folder = "ScreenshotFolder";
    public int frameRate = 25;
    void Start() {
        // Set the playback framerate (real time will not relate to game time after this).
        Time.captureFramerate = frameRate;
 
        // Create the folder
        System.IO.Directory.CreateDirectory(folder);
    }
 
 
    void Update() {
        // Append filename to folder name (format is '0005 shot.png"')
        string name = string.Format("{0}/{1:D04} shot.png", folder, Time.frameCount);
 
	    // Capture the screenshot to the specified file.
        Application.CaptureScreenshot(name);
    }
}

Time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文