simplestarの技術ブログ

目的を書いて、思想と試行、結果と考察、そして具体的な手段を記録します。

Unity:高画質スクリーンショット

ゲーム画面を高画質で記録したい

次のスクリプトをシーンに追加して、InputAction で KeyBoard > PrintScreen を指定したらできました。

PrintScreenshot.cs

using UnityEngine;
using UnityEngine.Experimental.Input;

public class PrintScreenshot : MonoBehaviour
{
    public InputAction inputAction;

    void Awake()
    {
        inputAction.performed += ctx =>
        {
            ScreenCapture.CaptureScreenshot(System.IO.Path.Combine(Application.dataPath, "../ScreenShots/" + System.DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".png"), 4);
        };
    }

    public void OnEnable()
    {
        inputAction.Enable();
    }

    public void OnDisable()
    {
        inputAction.Disable();
    }
}

参考記事

tsubakit1.hateblo.jp