Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Capturing a screenshot when running from CLI

Discussion in 'Testing & Automation' started by liortal, Mar 31, 2022.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I'd like to capture screenshots of certain playmode tests. Our CI process runs Unity from the CLI (e.g: passing them -runTests argument).

    I tried capturing screenshot using ScreenCapture.CaptureScreenshot, but unfortunately this method doesn't seem to work when running from the command line (when passing the -batchmode argument).

    Has anyone else encountered this problem? what can i do to capture screenshots when running our tests?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    I think that there is no 'screen' in batch mode, so a 'screenshot' is never really going to work. What you'll need to do is explicitly get your cameras to render to a texture instead.
     
    liortal likes this.
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Thanks @superpig i guess i'll try to go with this approach.