-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenshotCapture.cs
More file actions
61 lines (50 loc) · 2.07 KB
/
ScreenshotCapture.cs
File metadata and controls
61 lines (50 loc) · 2.07 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
50
51
52
53
54
55
56
57
58
59
60
61
using UnityEngine;
using System.IO;
public class ScreenshotCapture : MonoBehaviour
{
public Transform targetObject;
public int startAngleX = 0;
public int endAngleX = 360;
public int angleStepX = 30; // angle interval(x-axis)
public int startAngleY = 0;
public int endAngleY = 360;
public int angleStepY = 30; // angle interval(y-axis)
public string folderName = "Screenshot"; // Folder name to save
public string fileNamePrefix = "Screenshot";
// initial angle setting
private int currentAngleX = 0;
private int currentAngleY = 0;
void Start()
{
// If the folder does not exist, create a new folder
if (!Directory.Exists(targetObject.name))
{
Directory.CreateDirectory(targetObject.name);
}
string fileName = fileNamePrefix + "_X0" + currentAngleX.ToString() + "_Y0.png";
string filePath = Path.Combine(targetObject.name, fileName);
targetObject.rotation = Quaternion.Euler(0, 0, 0);
ScreenCapture.CaptureScreenshot(filePath);
}
void Update()
{
// If the current angle (x, y-axis) is less than or equal to 360 degrees, capture
if (currentAngleX < endAngleX && currentAngleY < endAngleY)
{
string fileName = targetObject.name + "_X" + currentAngleX.ToString() + "_Y" + currentAngleY.ToString() + ".png";
string filePath = Path.Combine(targetObject.name, fileName);
// Change the angle of the target object
targetObject.rotation = Quaternion.Euler(currentAngleX, currentAngleY, 0);
// Image Capture
ScreenCapture.CaptureScreenshot(filePath);
// Increase the y-axis angle
currentAngleY += angleStepY;
// If the y-axis angle reaches 360 degrees, set y-axis to 0 and x-axis to +15, then repeat
if (currentAngleY == endAngleY)
{
currentAngleY = startAngleY;
currentAngleX += angleStepX;
}
}
}
}