Search Unity

Application.CaptureScreenshot fails in compiled Mac app

Discussion in 'Editor & General Support' started by mstevenson, Jan 20, 2011.

  1. mstevenson

    mstevenson

    Joined:
    Sep 24, 2009
    Posts:
    189
    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:

    Code (csharp):
    1.  
    2. public void Start () {
    3.     Application.CaptureScreenshot ("Test shot.png");
    4. }
    5.  
    I've searched my hard drive hoping perhaps the image was stored in an unexpected location, but no luck so far.
     
  2. SemaphoreStudios

    SemaphoreStudios

    Joined:
    Jan 14, 2010
    Posts:
    111
    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?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    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
     
  4. mstevenson

    mstevenson

    Joined:
    Sep 24, 2009
    Posts:
    189
    I've searched completely through the bundle, still no dice.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Just tried it, it definitely show up in Contents/Data.

    --Eric
     
  6. mstevenson

    mstevenson

    Joined:
    Sep 24, 2009
    Posts:
    189
    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...
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Try it with "../../../" to make it appear outside the bundle.

    --Eric
     
  8. mstevenson

    mstevenson

    Joined:
    Sep 24, 2009
    Posts:
    189
    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!
     
  9. mstevenson

    mstevenson

    Joined:
    Sep 24, 2009
    Posts:
    189
    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.