I am trying to capture screenshots on Android, they need to appear in the Android gallery. So far I have been able to use Application.CaptureScreenshot successfully to take screenshots, but it only saves them in the default folder and the images won't show up in the android gallery.
I don't mind the default folder if this just worked, but why doesn't the screenshot appear in the gallery? Do I need to refresh it somehow?
But the folder path is a mystery too... For some reason I cannot set custom folder at all, when I tried it in unity editor and set the path to a folder on my computer I only get "Failed to store screen shot" error. It doesn't work on android either. Here is my code:
public void TakeScreenshot()
{
fileNumber = PlayerPrefs.GetInt ("FileNumber", 0);
fileNumber++;
PlayerPrefs.SetInt ("FileNumber", fileNumber);
fileName = ("ScreenShot" + fileNumber + ".jpg");
string myFolderLocation = "/storage/emulated/0/DCIM/UntitledProject/";
if(!System.IO.Directory.Exists(myFolderLocation)){
System.IO.Directory.CreateDirectory(myFolderLocation);
}
Application.CaptureScreenshot (myFolderLocation + fileName);
}
This code is able to create the directory just fine, but it never saves anything there. Any help is appreciated!
↧