CameraCapture.cs
1.02 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
using UnityEngine;
using System;
using System.Threading;
public class CameraCapture : MonoBehaviour
{
public static bool capture = false;
// The folder we place all screenshots inside.
// If the folder exists we will append numbers to create an empty folder.
public string folder = "ScreenCaptures";
public static int frameRate = 30;
public int sizeMultiplier = 1;
//string[] strArg;
public static int frameNumber = 0;
void Start()
{
string[] strArg = Environment.GetCommandLineArgs();
if (strArg.Length >= 2)
folder = strArg[1];
// Create the folder
folder = Application.persistentDataPath + "/" + folder;
System.IO.Directory.CreateDirectory(folder);
Debug.Log("ScreenCaptures to " + folder);
if (strArg.Length >= 4)
frameRate = int.Parse(strArg[3]);
Time.captureFramerate = frameRate;
}
void Update()
{
if (capture)
{
var name = string.Format("{0}/frame_{1}.png", folder, frameNumber++); // Time.frameCount);
Application.CaptureScreenshot(name, sizeMultiplier);
}
}
} // class