StationObscurum/Assets/Scripts/MainMenu/Screenshot.cs
2024-01-09 00:13:06 -05:00

32 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Screenshot : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{ // capture screen shot on left mouse button down
string folderPath = "Assets/Screenshots/"; // the path of your project folder
if (!System.IO.Directory.Exists(folderPath)) // if this path does not exist yet
System.IO.Directory.CreateDirectory(folderPath); // it will get created
var screenshotName =
"Screenshot_" +
System.DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss") + // puts the current time right into the screenshot name
".png"; // put youre favorite data format here
ScreenCapture.CaptureScreenshot(System.IO.Path.Combine(folderPath, screenshotName), 2); // takes the sceenshot, the "2" is for the scaled resolution, you can put this to 600 but it will take really long to scale the image up
Debug.Log(folderPath + screenshotName); // You get instant feedback in the console
}
}
}