Skip to content

Instantly share code, notes, and snippets.

@d12
Created July 19, 2021 18:52
Show Gist options
  • Save d12/a839e8d29dfd31b4bdc5097f96a4f75f to your computer and use it in GitHub Desktop.
Save d12/a839e8d29dfd31b4bdc5097f96a4f75f to your computer and use it in GitHub Desktop.
Takes a super high res screenshot in Unity 2019.4 when you press G.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public static class TakeScreenshot
{
// See http://docs.unity3d.com/ScriptReference/MenuItem.html for docs on [MenuItem] hotkeys
[MenuItem("Helpers/Screenshot _g")]
public static void Screenshot()
{
if (!Application.isPlaying)
{
Debug.LogError("Cannot take a screenshot unless the game is playing.");
return;
}
string path = $"Screenshots/{System.Guid.NewGuid()}.png";
ScreenCapture.CaptureScreenshot(path, 4);
Debug.Log($"Saved screenshot in {path}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment