困った時の自分用メモ

読んだ本を考察してメモったり、自分でいじった物の感想をメモったりする場。週1更新を目指します。

UnityEditorの話~GameViewのスクリーンショットを撮影する方法~

qiita.com

この人の方法を参考にした。

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
    }