Capture screenshots which include the UI?

Hey guys, how would one go about capturing a screenshot of the game with the new GUI rig? in the Webplayer.

Previously, I would

        Texture2D screenShot = new Texture2D(1920, 1080, TextureFormat.RGB24, false);
        RenderTexture rt = new RenderTexture(screenShot.width, screenShot.height, 24);

        //Render from all!
        foreach (Camera cam in Camera.allCameras)
        {
            RenderTexture prev = cam.targetTexture;
            cam.targetTexture = rt;
            cam.Render();
            cam.targetTexture = prev;
        }

        RenderTexture.active = rt;
        screenShot.ReadPixels(new Rect(0, 0, screenShot.width, screenShot.height), 0, 0);

//various other post processing here..

        screenShot.Apply();

        SaveScreenshotToGallery(screenShot);

Is there an extra UI camera that I can render in also?

What is your Canvas Render Mode set to?

Screen space overlay for the main ui

Switched to a Screen Space - Camera to try and work around the issue, to no avail, my new uiCamera does show up in the allcameras listing, but rendering it into a texture does not appear to give any results.

Exposed a couple problems that should be bug reports.

ScreenSpace - Camera + Reference resolution = some shall we say, non intuitive values output in the scales and Z depths of things.
Instantiating ui prefabs onto a screen space camera canvas causes problems that were not there when dealing with the ScreenSpace overlay mode, I now need to zero out the localPosition.z and set the localScale to 1 on all runtime prefabs that I add to the hierarchy.

So anyway, any other thoughts of directions to try for capturing the UI?

Hi Dave,
I had the same issue here -

Phil from unity said it sounds like a bug (I’ll file it later this week)
Not sure about a workaround, I didn’t have time to try anything yet…

i 90% sure it a ordering issue in the render pipeline. The canvas doesnt emit its geometry at the proper times outside the render loop it will need to get fixed once a bug is filed.

I saw Stephane had a case number 631091 already, so I haven’t re-submitted…

[edit: un-mangled name!]

yup it also needs to get through QA to get to the devs so i think we’re waiting on thats as well.

I have the same problem, rendertexture not capturing the Gui.

However I couldn’t find an issue under number 631091. Is this an issue and is it registered, so I can vote and follow;)

Or does anybody already have a solution?

same here…
Using Unity4.6f3 the problem still exist…
damn i need RT the uGui in my project… just waited for final 4.6 and still can not ship

@Muckel can you send me your project as well so i can test against it.

yes sure!
see PM.

Does this bug got fixed?

hopefully in 4.6.2p1 should be out soon

I just ran into this bug today and boy was I surprised to find that it had been fixed in a patch release released TODAY. 4.6.2p1 worked perfectly for me. What perfect timing :smile:

Waiting patiently for it to hit 4.6.3 so I can have a webplayer :slight_smile:

:slight_smile: Glad it works for you.

Yea :frowning: that might be a little bit yet as we usually have 4 patches between majour