Hello Unity-Community. I have a problem with my function, which should save a screenshot to a desired path:
public void TakeScreenshot()
{
string folderPath = "Screenshots/";
if (!System.IO.Directory.Exists(folderPath))
System.IO.Directory.CreateDirectory(folderPath);
var screenshotName =
"Screenshot_" +
System.DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss") +
".png";
ScreenCapture.CaptureScreenshot(System.IO.Path.Combine(folderPath, screenshotName));
Debug.Log(folderPath + screenshotName);
}
Although it perfectly works fine when using inside the Editor, it doesn’t work when I export my project. The Screenshots folder is going to be created at the desired place, but the screenshots won’t be saved. If I take the folderPath out of the Screen Capture Process, the screenshot will be created but inside of the “Data” Folder. What can I do?