この人の方法を参考にした。
using UnityEditor; using UnityEngine; public class CaptureScreenshotFromEditor : Editor { [MenuItem("ShortCutCommand/CaptureScreenshot")] private static void CaptureScreenshot() { // 階層はAssetsフォルダが存在する階層に出力されるので、 // パス指定で書き出し場所も変更可能 string fileName = "screenshot.png"; #if UNITY_2017_1_OR_NEWER ScreenCapture.CaptureScreenshot(fileName); #else Application.CaptureScreenshot(fileName); #endif }