Skip to content

Instantly share code, notes, and snippets.

@jstadler
Created March 17, 2014 06:53
Show Gist options
  • Save jstadler/9594987 to your computer and use it in GitHub Desktop.
Save jstadler/9594987 to your computer and use it in GitHub Desktop.
Unity3D C# script to write each frame to disk.
using UnityEngine;
using System.Collections;
public class FrameDump : MonoBehaviour {
string folder = "frame dumps";
int frameCount;
// Initialization
void Start () {
// delete folder (and anything inside it) if it exists
if( System.IO.Directory.Exists(folder) ){
System.IO.Directory.Delete(folder, true);
}
// create the folder for dumps
System.IO.Directory.CreateDirectory(folder);
// initialize frame counter to 0
frameCount = 0;
}
// Update is called once per frame, writes each frame to disk
void Update () {
string filename = string.Format("{0:000000}", frameCount);
Application.CaptureScreenshot("../" + folder + "/" + filename + ".jpg");
frameCount++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment