Skip to content

Instantly share code, notes, and snippets.

@griv griv/SaveFrames.cs
Last active Aug 29, 2015

What would you like to do?
Renders Unity Camera.main to png images.
using UnityEngine;
using System.Collections;
using System;
public class SaveFrames : MonoBehaviour {
public bool saveFrames = false;
public bool saveFrameHotKey = false;
public string folderPrefix = "frames_out";
public int frameRate = 25;
public int frameSizeMultiplier = 1;
private string nowTime;
private string fullFolderName;
void Start() {
nowTime = String.Format("{0:yyyyMMdd_HHmmss}", DateTime.Now);
fullFolderName = String.Format("{0}_{1}", folderPrefix, nowTime);
Time.captureFramerate = frameRate;
void LateUpdate() {
if (saveFrames || (saveFrameHotKey && Input.GetKey(KeyCode.S))) {
string name = String.Format("{0}/frame_{1:D04}.png", fullFolderName, Time.frameCount);
Application.CaptureScreenshot(name, frameSizeMultiplier);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.