Is Application.CaptureScreenshot meant to work in compiled builds? The following code works in the Editor, but does nothing when compiled as a Mac app:
public void Start () {
Application.CaptureScreenshot ("Test shot.png");
}
I’ve searched my hard drive hoping perhaps the image was stored in an unexpected location, but no luck so far.
The same thing happens on PC by the way which is a petty since I really want to capture full frames at 1920x1080 (or even 720) but if you do it from the editor then you will get the upper part of the screen filled with the editor gui.
Anyone from Unity Technologies can shed some light on this please?
Look inside the app bundle, specifically Contents/Data. If you want it to appear outside the app bundle, you have to specify that in the path. (Namely, “…/…/…/Test shot.png”.)
–Eric
I’ve searched completely through the bundle, still no dice.
Just tried it, it definitely show up in Contents/Data.
–Eric
Hmm… I’m just seeing mainData, Managed (folder full of dlls), resources.assets, and sharedassets0.assets. I compared the size of the bundle in bytes before and after running it for the first time and there’s no change. Very strange…
Try it with “…/…/…/” to make it appear outside the bundle.
–Eric
I made a new project and copied my scripts over, and now screenshots correctly appear in Contents/Data in this new build. I’ll poke around and see if maybe there’s a permissions issue with the other project. It was pulled down from a subversion repo, so it may be a little wonky.
Thanks for the help!
I think I found the issue. I was taking a screenshot on Start in two different scripts. One script was using a relative path for the filename, the other was using just a name. This works in the editor, but in a compiled build it seems always to fail unless you push the path back out of the application bundle using …/…/…/ as you suggested. The strange part, though, is that when one CaptureScreenshot call fails, they all fail, even if the other ones are using the correct parameters. This is a crazy edge case, but I’ll file a bug report.