- Home /
Why doesn't Application.CaptureScreenshot work in Windows player?
Hi! I want to capture a screenshot and wrote a following script to do this:
void Update ()
{
if (Input.GetButtonDown ("Screenshot"))
{
if (!Directory.Exists ("Screenshots"))
Directory.CreateDirectory ("Screenshots");
int index = Directory.GetFiles ("Screenshots").Length + 1;
Application.CaptureScreenshot ("Screenshots/Screenshot" + index.ToString () + ".png");
}
}
While in editor playmode it works fine, when I build the game for Windows it doesn't. It just leaves an empty folder no matter how many times the button is pressed(f2). Please help!
Answer by Wanzyee · Sep 18, 2015 at 10:30 AM
Hi guy! I faced this exactly the &#$% problem today, and finally figured it out... Application.CaptureScreenshot works fine in editor.
BUT! It doesn't accept my relative file path in Windows player. So...just feed it an ABSOLUTE path...then you get the shot.
BTW, I can't save screenshot in the root of drive, like E:.
$$anonymous$$ost of those "limitations" are caused by Windows itself. It's a matter of permissions. Relative path are always dangerous if you're not 100% sure you know the "current directory". Even then there always have been several applications / API functions / ... that doesn't properly support relative paths.
Even NTFS has several really nice features it always was and will be the developers nightmare ^^. I miss the simple structure of FAT32.
Your answer
Follow this Question
Related Questions
Application.OpenURL() Rapid Opening 1 Answer
Failed to Update Unity Web Player on multiple browsers 0 Answers
How to Read Data from a Bluetooth Device with a Windows Store App 3 Answers
Can't capture Multiple Screenshots in one Second 1 Answer
Accessing the bytes[] from Application.CaptureScreenshot 1 Answer