TakeScreenshotInEditor

From Unify Community Wiki
Jump to: navigation, search

Author: Jonathan Czeck (aarku)

Description

This editor script takes screenshots for you when you press command-control-s. The screenshots are numbered dependant on the existing files and are placed in the root level of your project. As of Unity 1.2.2, there are bugs or lack of features that allow the menu item to be placed in a location like the Window or File menu.

Usage

Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the Custom menu after it is compiled.

C# - TakeScreenshotInEditor.cs

using UnityEngine;
using UnityEditor;
 
public class TakeScreenshotInEditor : ScriptableObject
{
    public static string fileName = "Editor Screenshot ";
    public static int startNumber = 1;
 
    [MenuItem ("Custom/Take Screenshot of Game View %^s")]
    static void TakeScreenshot()
    {
        int number = startNumber;
        string name = "" + number;
 
        while (System.IO.File.Exists(fileName + name + ".png"))
        {
            number++;
            name = "" + number;
        }
 
        startNumber = number + 1;
 
        Application.CaptureScreenshot(fileName + name + ".png");
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools