Possible to export an image of scene/game view, in defined resolution?

I find it insanely time consuming to supply screenshots for the iOS app store as they MUST be of iOS device resolution. It takes soooo much time to build and run on all devices, take screenshots and upload. And then the next day you notice a typo and have to redo that full hour of work. Not to mention for each little update you start slacking on updating your screenshots because it is simple too time consuming. There must be someone before me that found a faster/better way of doing so.

I am looking for a way within the unity editor to just export a image of what every is in my game view, but in a defined resolution. I did find one plugin that were supposed to do this, but for some reason it only works for a camera? not a canvas, not replicating what is in the actual game view.

Hi @rpuls !

Please take a look at this method: Unity - Scripting API: ScreenCapture.CaptureScreenshot

What it does is to capture a Screenshot of your game, the following Script will add a Menu to the Editor so you can capture an image.

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

public class ScreenshotGrabber
{
    [MenuItem("Screenshot/Grab")]
    public static void Grab()
    {
        ScreenCapture.CaptureScreenshot("Screenshot.png", 1);
    }
}
#endif

You just need to adjust the resolution of your game view and hit Screenshot > Grab.
The second parameter will allow you to scale the resulting image, so if you set it to 1, you will get an image at the exact resolution of your game view, if you set it to 2, you will get an image scaled two times.

5 Likes

I have to ask, where is the file “Screenshot.png” being saved at ?

I am talking about using this function in Unity Editor, while playing Game View

It’s saved in the project root. If, for some reason, you want it more readily accessible in the editor, you can prefix the screenshot name with “Assets” like

ScreenCapture.CaptureScreenshot("Assets/Screenshot.png", 1);

I modified the handy ScreenshotGrabber class a little for my purposes:

#if UNITY_EDITOR
using UnityEditor;

public class ScreenshotGrabber
{
    [MenuItem("Screenshot/Grab")]
    public static void Grab()
    {
        ScreenCapture.CaptureScreenshot("Screenshot" + GetCh() + GetCh() + GetCh() +  "_" + Screen.width+"x"+Screen.height+".png", 1);
    }

    public static char GetCh()
    {
        return (char)UnityEngine.Random.Range('A', 'Z');
    }
}
#endif

I wanted to take multiple screenshots at various resolutions to provide to a store listing. Pretty common scenario.

4 Likes