It works great in the Editor, but on Android device I got an error that this file can not be written.
AndroidPlayer([email protected]:34999) Failed to store screen shot (/storage/emulated/0/Android/data/com.DefaultCompany.Test3D/files/storage/emulated/0/Android/data/com.DefaultCompany.Test3D/files/Screenshots/LastPhoto.png)
What’s wrong ?
I use this code:
public static string MakeScreenShot()
{
string directoryPath =Path.Combine(Application.persistentDataPath ,"Screenshots");
if(!Directory.Exists(directoryPath))
{
//if it doesn't exist, create it
Directory.CreateDirectory(directoryPath);
}
string fPath = Path.Combine(directoryPath,"LastPhoto.png");
ScreenCapture.CaptureScreenshot(fPath);
Debug.Log("Screenshot created " + fPath);
return fPath;
}
I can write the file with File command - same path, no problems var tex = new Texture2D(100, 100, TextureFormat.RGB24, false); var bytes = tex.EncodeToPNG(); File.WriteAllBytes(Path.Combine(directoryPath,"LastPhoto1.png"), bytes); But ScreenCapture.CaptureScreenshot doesn't work. What's up ?
– PricefixingDid you find something about this? I'm having the same problem with UWP.
– Dooryard