-
Notifications
You must be signed in to change notification settings - Fork 1
/
TakeScreenshot.cs
33 lines (26 loc) · 1 KB
/
TakeScreenshot.cs
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
// TODO:
// By default, screenshot files are placed next to the executable bundle -- we don't want this in a
// shipping game, as it will fail if the user doesn't have write access to the Applications folder.
// Instead we should place the screenshots on the user's desktop. However, the ~/ notation doesn't
// work, and Unity doesn't have a mechanism to return special paths. Therefore, the correct way to
// solve this is probably with a plug-in to return OS specific special paths.
// Mono/.NET has functions to get special paths... see discussion page. --Aarku
using UnityEngine;
using System.Collections;
public class TakeScreenshot : MonoBehaviour
{
private int screenshotCount = 0;
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
string screenshotFilename;
do
{
screenshotCount++;
screenshotFilename = "screenshot" + screenshotCount + ".png";
} while (System.IO.File.Exists(screenshotFilename));
Application.CaptureScreenshot(screenshotFilename,3);
}
}
}