게임플레이를 동영상으로 녹화하는 것은 시간 관리에 있어 특수한 경우에 해당합니다. 화면 이미지를 저장하는 작업은 시간이 많이 걸리기 때문에 게임의 일반 프레임 속도가 줄어들고 동영상은 게임의 실제 성능을 반영하지 못합니다.
동영상의 외형을 개선하려면 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의 다른 값을 사용해 보십시오.