I’m sorry Application.CaptureScreenshot(Application.persistentDataPath);
it simply does not do anything. It does not save the photo anywhere I can find it. There’s something else I need to be doing here, I don’t know what it is. Maybe there’s something I’m forgetting,
but it works perfectly when running the unity program on my PC. I doesn’t work at all on Android.
Application.screenshot(); just doesn’t work for me. you also might want to call the manuallycodedScreenshot inside an iEnumerator.
If someone is experiencing this issue here’s how to fix it:
Texture2D screencap;
string screenshotPath;
void Start() {
screencap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
screencap.Apply();
screenshotPath = (runningOnPC ? Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
: Application.persistentDataPath) + "/TSM_Screenshots/";
}
void manuallyCodedScreenshot()
{
screencap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, true);
screencap.Apply();
byte[] screenshotEncodedinBytes = screencap.EncodeToPNG();
File.WriteAllBytes(screenshotPath, screenshotEncodedinBytes);
}