Screenshot capturing tool for Unity. Video tutorial. Part 1

This tutorial is about writing automatic screen shot capturing tool for Unity. You know this is always pain to make game screenshots for multiple devices and platforms when you have plenty of resolutions. So this tool makes life match easier.

Hook Wars: Run, Pudge, Run!

There are a couple of ways how to implement screenshot capturing. First you can use R2T, attach it and take a screenshot directly from game camera, but this approach have a lot of drawbacks and are complicated for implementation. If you want to try it you can look into this unity store plug-in called Instant Screenshot.

In this tutorial I will show you I think better and easiest way to take screenshots. We will just manually resize GameView window and then use CaptureScreenshot function of Application class.

In the next tutorial I will show how to implement multiple screenshot taking and hi resolution screenshots support.

ScreenshotTaker script from the video

using UnityEngine;
using System.Collections;
using UnityEditor;

public class ScreenshotTaker
    public static void MenuItem_TakeScreenshots()
        //get game view
        System.Type gameViewType = System.Type.GetType("UnityEditor.GameView, UnityEditor");
        var gameView = EditorWindow.GetWindow(gameViewType);
        if (gameView == null)

        gameView = EditorWindow.GetWindow(gameViewType);
        if (gameView == null)
            Debug.LogError("Game View not find!");

        //resize game view
        int width = 1024;
        int height = 768;
        int gameViewBarHeight = 17;

        var rect = gameView.position;
        rect.x = 0;
        rect.y = 0;
        rect.width = width;
        rect.height = height + gameViewBarHeight;
        gameView.position = rect;

        //take screenshot
        string fileName = "screenshot_" + System.DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".png";
        string folderPath = Application.persistentDataPath;
        fileName = System.IO.Path.Combine(folderPath, fileName);

Write a comment