<aside> 📄 This script is intended for use with the “RightClickCapture” script. Use these scripts to take hi-res images of your project during play in the Unity editor. Add the script to an empty GameObject in the scene. As you take pictures, manually change the filename. The photos will be uploaded to a new folder called Screenshots in the Assets folder. For highest resolution, change multiplier to 4.

</aside>

using UnityEngine;

public class ScreenshotCapture : MonoBehaviour
{
    public string folderName = "Screenshots";
    public string fileName = "screenshot";
    public int resolutionMultiplier = 2; // Adjust this value for higher resolution

    public void Capture()
    {
        string folderPath = UnityEngine.Application.dataPath + "/" + folderName; // Specify UnityEngine.Application
        if (!System.IO.Directory.Exists(folderPath))
            System.IO.Directory.CreateDirectory(folderPath);

        string filePath = folderPath + "/" + fileName + ".png";
        ScreenCapture.CaptureScreenshot(filePath, resolutionMultiplier);
        UnityEngine.Debug.Log("Screenshot captured at: " + filePath); // Specify UnityEngine.Debug
    }
}