Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Capture screenshots which include the UI?

Discussion in 'Unity UI & TextMesh Pro' started by davebuchhofer, Oct 14, 2014.

  1. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Hey guys, how would one go about capturing a screenshot of the game with the new GUI rig? in the Webplayer.

    Previously, I would

    Code (csharp):
    1.  
    2.         Texture2D screenShot = new Texture2D(1920, 1080, TextureFormat.RGB24, false);
    3.         RenderTexture rt = new RenderTexture(screenShot.width, screenShot.height, 24);
    4.  
    5.         //Render from all!
    6.         foreach (Camera cam in Camera.allCameras)
    7.         {
    8.             RenderTexture prev = cam.targetTexture;
    9.             cam.targetTexture = rt;
    10.             cam.Render();
    11.             cam.targetTexture = prev;
    12.         }
    13.  
    14.         RenderTexture.active = rt;
    15.         screenShot.ReadPixels(new Rect(0, 0, screenShot.width, screenShot.height), 0, 0);
    16.  
    17. //various other post processing here..
    18.  
    19.         screenShot.Apply();
    20.  
    21.         SaveScreenshotToGallery(screenShot);
    22.  
    Is there an extra UI camera that I can render in also?
     
  2. jim0_o

    jim0_o

    Joined:
    Jul 14, 2013
    Posts:
    6
    What is your Canvas Render Mode set to?
     
  3. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Screen space overlay for the main ui
     
  4. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    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?
     
  5. assaf-cohen

    assaf-cohen

    Joined:
    Sep 27, 2013
    Posts:
    78
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,053
    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.
     
  7. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    I saw Stephane had a case number 631091 already, so I haven't re-submitted..


    [edit: un-mangled name!]
     
  8. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,053
    yup it also needs to get through QA to get to the devs so i think we're waiting on thats as well.
     
  9. fertigo

    fertigo

    Joined:
    Feb 15, 2014
    Posts:
    17
    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?
     
  10. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    407
    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
     
  11. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,053
    @Muckel can you send me your project as well so i can test against it.
     
  12. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    407
    yes sure!
    see PM.
     
  13. cesarpo

    cesarpo

    Joined:
    Jun 8, 2013
    Posts:
    98
    Does this bug got fixed?
     
  14. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,053
    hopefully in 4.6.2p1 should be out soon
     
  15. ruddonomy

    ruddonomy

    Joined:
    Mar 2, 2013
    Posts:
    1
    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 :D
     
  16. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    Waiting patiently for it to hit 4.6.3 so I can have a webplayer :)
     
  17. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,053
    :) Glad it works for you.
    Yea :( that might be a little bit yet as we usually have 4 patches between majour