TakeScreenshotInEditor

From Unify Community Wiki
Revision as of 20:16, 16 April 2006 by 71.210.145.66 (Talk)

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 a more sensible keyboard shortcut (say, command-shift-5) and 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

<csharp> 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 (name.Length < 3)
           name = 0 + name;
       
       while (System.IO.File.Exists(fileName + name))
       {
           number++;
           name = "" + number;
           while (name.Length < 3)
               name = 0 + name;
       }
       
       startNumber = number + 1;
       
       Application.CaptureScreenshot(fileName + name + ".png");
   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox