I want to capture screenshots by pressing the mouse wheel button and save them all automatically in a folder. I found a link to screen capture script reference, but how can I change the button? and how do I assign the folder it saves the images to? This should be easy, right? Please help
Here is the right answer:
using System;
using UnityEngine;
public class screenshot : MonoBehaviour
{
private void Update()
{
if (Input.GetMouseButtonDown(2))
{
ScreenCapture.CaptureScreenshot(Application.dataPath + "/screenshots/" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".png");
UnityEditor.AssetDatabase.Refresh();
}
}
}
Thanks @PaulaOstupe for posting this. Exactly what I wanted! Sweet!
Hey @Rizz90, I’m sure you figured this out a long time ago but for anyone else who needs to know how to save a screenshot to the Windows Documents folder, change Paula’s code to this:
ScreenCapture.CaptureScreenshot(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/Screenshots/" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".png");
I tried this on WIndows 11 and it works great!