Version: Unity 6.0 (6000.0)
言語 : 日本語
ゲーム内時間とリアルタイム
Simulate hitches for testing

キャプチャフレームレート

時間管理における特殊なケースとして、ゲームをビデオとして記録する場合があります。画面映像の保存作業にはかなりの時間がかかるため、ゲームのフレームレートが通常より低下し、本来のパフォーマンスがビデオに反映されません。

ビデオの表示を改善するには、Capture Framerate プロパティを使用します。このプロパティのデフォルト値は 0 であり、録画しないゲームプレイ用に設定されています。プロパティの値を 0 以外の値に設定した場合、ゲーム時間は遅くなり、録画のために一定間隔で正確にフレーム更新が行われます。フレーム間隔は、1 / Time.captureFramerate に一致するため、5.0 に値を設定した場合、更新が 1/5 秒ごとに発生します。フレームレートへの要求を効果的に削減すると、Update 関数内でスクリーンショットを保存したり、他の操作を実行したりする時間ができます。

//C# script example
using UnityEngine;
using System.Collections;

public class ExampleScript : MonoBehaviour {
    // 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.
    string folder = "ScreenshotFolder";
    int frameRate = 25;
        
    void Start () {
        // Set the playback frame rate (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.captureFramerate にさまざまな値を試して、適切にバランスをとるようにしてください。

追加リソース

ゲーム内時間とリアルタイム
Simulate hitches for testing