CameraCapture.cs
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*************************************************
* @Author: Icaro Magalhaes
*************************************************/
using UnityEngine;
using System;
using System.Threading;
public class CameraCapture : MonoBehaviour{
// The folder we place all screenshots inside.
// If the folder exists we will append numbers to create an empty folder.
public string folder;
public int frameRate = 30;
public int sizeMultiplier = 1;
string[] strArg;
bool beginning = true;
void Start( ){
Debug.Log ("Folders can be found inside "+Application.persistentDataPath);
strArg = Environment.GetCommandLineArgs();
folder = strArg[1];
/*if( strArg.Length == 4 ) frameRate = int.Parse(strArg[3]);*/
Debug.Log ("Folders can be found inside "+Application.persistentDataPath);
// Set the playback framerate!
// (real time doesn't influence time anymore)
Time.captureFramerate = frameRate;
// Find a folder that doesn't exist yet by appending numbers!
//realFolder = folder;
// Create the folder
System.IO.Directory.CreateDirectory(Application.persistentDataPath+"/"+folder);
folder = Application.persistentDataPath+"/"+folder;
} // Start
void Update( ){
if (beginning) {
beginning = false;
Thread.Sleep(500);
}
else {
var name = string.Format("{0}/frame_{1}.png", folder, Time.frameCount);
Application.CaptureScreenshot(name, sizeMultiplier);
}
}
} // class