
Implementation
Here’s a simple script you can add to your Unity projects to take screenshots.
-
Create a
C#
fileAssets/Editor/CaptureScreenshotWindow.cs
and paste the following code:public class CaptureScreenshotWindow : EditorWindow { private static string lastScreenshot = "No screenshot taken yet..."; private void OnGUI() { GUILayout.Label("Screenshot Tool", EditorStyles.boldLabel); if (GUILayout.Button("Capture Screenshot")) { CaptureScreenshot(); } GUILayout.Space(10); GUILayout.Label("Last Screenshot:", EditorStyles.label); GUILayout.TextField(lastScreenshot); } [MenuItem("Tools/Screenshot/Open Screenshot Window")] public static void ShowWindow() { CaptureScreenshotWindow window = GetWindow<CaptureScreenshotWindow>("Screenshot Tool"); window.minSize = new Vector2(300, 100); } [MenuItem("Tools/Screenshot/Capture Screenshot Now")] public static void CaptureScreenshot() { // Generate Filename int randomIdx = RandomUtils.GenerateRandomNumber(); string timestamp = DateTimeUtils.GetCurrentTimestamp(); // Create folder path string folderPath = Path.Combine(Application.dataPath, "../Screenshots"); Directory.CreateDirectory(folderPath); // Ensure the folder exists string filenameOnly = $"screenshot_{timestamp}_{randomIdx}.png"; string fullPath = Path.Combine(folderPath, filenameOnly); // Capture Screenshot (relative to project root) ScreenCapture.CaptureScreenshot(Path.Combine("Screenshots", filenameOnly)); // Show a popup in the Unity Editor EditorUtility.DisplayDialog("Screenshot Captured", $"Screenshot saved as:\n{fullPath}", "OK"); lastScreenshot = fullPath; } }
-
In the top menu, go to Tools → Screenshot → Open Screenshot Window.
-
Take a screenshot! You’ll find it in the
Screenshots
folder at your project root.
That’s all! Hope it is helpful!
Tip: Adjust your game view resolution before capturing the screenshot.