Created
March 17, 2014 06:53
-
-
Save jstadler/9594987 to your computer and use it in GitHub Desktop.
Unity3D C# script to write each frame to disk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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