How I take Screenshots for the App Store

When you add a game to the Apple App Store or Google Play Store, you need screenshots in many different dimensions. The screenshots are meant to show the game as it appears on various phones and tablets with many different sizes.

Take Unity Screenshots in multiple sizes simultaneously

In Unity, I wrote a script to take the screenshots from a PC build. I can specify a list of the dimensions for as many screenshots as I need, and the location of a folder to save them.

In a PC build, when I right-click, it pauses the game by setting Time.timescale to 0, then it resizes the game window to the first size in my list, such as 800x600, it waits a moment so the UI can update it’s position, then it saves a screenshot as a PNG file, moves to the next size in my list, and repeats until it’s taken all the screenshots I need. After it’s done, it resumes the game by setting Time.timescale back to 1.

Take a Unity Screenshot bigger than the display size

The problem I found, was that Windows and Mac both prevented the game from having a width or height larger than my display size. My display is 3440x1440, and I needed a screenshot at 2732x2048, but was getting a screenshot taken at 2732x1440. I believe this would not be a problem on a 4K display, multiple displays that expand the desktop, or maybe with a virtual desktop.

The solution I found was to use my video card. In the Nvidia Control panel, I made a fake custom resolution of 6880x2880, and then I was able to take the screenshots. There was a popup warning that doing this could damage your display, so be careful if you try it, but it worked fine for me.

Here’s the script I wrote:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class screenShot : MonoBehaviour
{
    // Singleton instance for easy access from other scripts
    public static screenShot instance;

    // Flag to enable/disable screenshot functionality
    public bool takeScreenshots = false;

    // Default location to save screenshots

    //Windows//
    public string screenshotLocation = "C:\\Users\\yourName\\Desktop\\screenshots";

    //Mac//
    //public string screenshotLocation = "/Users/yourName/Desktop/screenshots";


    // Array of resolutions to cycle through when taking screenshots
    public string[] resolutions;//640x480 etc;

    // Private variables for tracking screen dimensions and screenshot process
    private int width;
    private int height;
    private int screenN;
    private bool scalingScreen = false;
    private bool takingScreens = false;
    private float waitF;

    // Singleton pattern to ensure only one instance exists
    void Awake()
    {
        if (instance)
        {
            // Destroy duplicate instances
            Destroy(gameObject);
        }
        else
        {
            // Set the instance to this object and persist across scenes
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
    }

    // Set screen resolution based on the provided string
    public void setXY(string _res)//separated ints with x//
    {
        // Split the resolution string into width and height
        string[] splitNs = _res.Split('x');
        width = int.Parse(splitNs[0]);
        height = int.Parse(splitNs[1]);

        // Set the screen resolution
        Screen.SetResolution(width, height, false);
    }


    // Update is called once per frame
    void Update()
    {
        // Check if screenshot functionality is enabled
        if (takeScreenshots)
        {
            // Start taking screenshots when right mouse button is pressed
            if (!takingScreens)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    // Play a sound effect
                    //soundManager.sound.playSFX(26);

                    // Initialize variables for taking screenshots
                    screenN = 0;
                    scalingScreen = true;
                    takingScreens = true;
                    Time.timeScale = 0f;
                }
            }
            // Scale the screen resolution
            else if (scalingScreen)
            {
                if (Time.realtimeSinceStartup > waitF)
                {
                    // Set the screen resolution and update wait time
                    setXY(resolutions[screenN]);//resolution will not update until the next frame//
                    waitF = Time.realtimeSinceStartup + 2f;
                    scalingScreen = false;// Stop scaling
                }
            }
            //take screenshots//
            else
            {
                if(Time.realtimeSinceStartup > waitF)
                {
                    // Capture screenshot
                    takeScreenshot(screenN);

                    // Check if more screens to capture
                    if (screenN + 1 < resolutions.Length)
                    {
                        screenN++;
                        scalingScreen = true;// Start scaling for the next resolution

                        waitF = Time.realtimeSinceStartup + 2f;
                    }
                    //finished taking screenshots
                    else
                    {
                        takingScreens = false;
                        Time.timeScale = 1f;// Resume the game
                    }
                }
            }
        }
    }

    // Capture screenshot with a given index in resolutions array
    void takeScreenshot(int _num)
    {
        // Save the screenshot with a filename containing resolution and timestamp
        ScreenCapture.CaptureScreenshot(screenshotLocation + "\\haunt"+ resolutions[_num]+"_"+System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".png");
    }

}