# Unity - get screenshots from various resolutions

To upload my app to Google Play I need to provide various screenshots. Thing is, I have only one tablet, no phone and I don't feel like virtualizing a bunch of devices. Is there a way to create screenshots of different sizes? Like what would a 7" 1280X720 tablet see?

• You know you can set the Game window in the editor to any particular resolution you want, right? Is this not sufficient for your needs? – DMGregory Aug 24 '17 at 22:32
• If I make a screenshot with a resolution set to, say, 1280X720, using capture screenshot like every 10th frame so I don't need to manually scnreenshot, will that be like I did that on a 1280X720 5" phone? On Play even the phone screen size is determined, unsure if the screen size will match too. The screenshot size should be fine though – agiro Aug 25 '17 at 14:45
• So, to clarify, is there a difference between a 1280X720 5" phone screenshot and a 1280X720 10" tablet screenshot? – agiro Aug 25 '17 at 14:46
• That sounds like a different question. Did you code your game to switch any behaviour or assets depending on the device's ID, physical size, or pixel density? (eg. making buttons larger in pixel size on the phone so they're still a comfortable size to touch on the smaller screen)? If you didn't, then where would such a difference come from? – DMGregory Aug 25 '17 at 14:57
• I checked it on 2 real (cheap) tablets, and on any screen resolutions Unity has to offer and all was fine :D In the question, indeed I was sloppy, but the "size" referred to the screen's physical size. I don't know where would they come from, that's why I'm asking (though I guess there shouldn't be difference, resolution matters). The tablets I have are just about the same screen size, just different manufacturers. – agiro Aug 25 '17 at 15:06

Add this handy script to an empty game object.
Screenshot Key speaks for itself - you use it during play to take screenshots. They will be saved in "Screenshots" inside your project folder.
Scale factor is what you need to take screenshots of display sizes which you don't own.
Example: build settings, switching to Android. In left up corner of Game View instead of default free aspect set to what you need. Scale factor is for when you have to take screenshots of resolutions you don't own(need 2048x1536 while your monitor is 1024x768). For this particular case just scale it by 2.

using UnityEngine;
using System.Collections;
using System.IO; // included for access to File IO such as Directory class

/// <summary>
/// Handles taking a screenshot of game window.
/// </summary>
public class ScreenshotUtility : MonoBehaviour
{
// static reference to ScreenshotUtility so can be called from other scripts directly (not just through gameobject component)
public static ScreenshotUtility screenShotUtility;

#region Public Variables
// The key used to take a screenshot
public string m_ScreenshotKey = "s";
// The amount to scale the screenshot
public int m_ScaleFactor = 1;
#endregion

#region Private Variables
// The number of screenshots taken
private int m_ImageCount = 0;
#endregion

#region Constants
// The key used to get/set the number of images
private const string ImageCntKey = "IMAGE_CNT";
#endregion

/// <summary>
/// Lets the screenshot utility persist through scenes.
/// </summary>
void Awake ()
{
if (screenShotUtility!=null) { // this gameobject must already have been setup in a previous scene, so just destroy this game object
Destroy(this.gameObject);
} else { // this is the first time we are setting up the screenshot utility
// setup reference to ScreenshotUtility class
screenShotUtility = this.GetComponent<ScreenshotUtility>();

// keep this gameobject around as new scenes load

// get image count from player prefs for indexing of filename
m_ImageCount = PlayerPrefs.GetInt(ImageCntKey);
}

// if there is not a "Screenshots" directory in the Project folder, create one
if (!Directory.Exists("Screenshots")) {
Directory.CreateDirectory("Screenshots");
}

}

/// <summary>
/// Called once per frame. Handles the input.
/// </summary>
void Update ()
{
// Checks for input
if (Input.GetKeyDown(m_ScreenshotKey.ToLower()))
{
// Saves the current image count
PlayerPrefs.SetInt(ImageCntKey, ++m_ImageCount);

// Adjusts the height and width for the file name
int width = Screen.width * m_ScaleFactor;
int height = Screen.height * m_ScaleFactor;

// Takes the screenshot with filename "Screenshot_WIDTHxHEIGHT_IMAGECOUNT.png"
// and save it in the Screenshots folder
ScreenCapture.CaptureScreenshot("Screenshots/Screenshot_" +
+ width + "x" + height
+ "_"
+ m_ImageCount
+ ".png",
m_ScaleFactor);
}
}
}

• For now, ScreenCapture.CaptureScreenshot is buggy, filed a report too. In the meantime I found a solution that works fine, here's the answer: gamedev.stackexchange.com/questions/147629/… – agiro Aug 26 '17 at 7:59