Skip to content

Instantly share code, notes, and snippets.

@oismaelash
Created July 29, 2019 23:36
Show Gist options
  • Save oismaelash/6126436bc1ea08f577b9116ba1a1403b to your computer and use it in GitHub Desktop.
Save oismaelash/6126436bc1ea08f577b9116ba1a1403b to your computer and use it in GitHub Desktop.
private IEnumerator Screenshot_Coroutine()
{
yield return new WaitForEndOfFrame();
Texture2D screenshot = ScreenCapture.CaptureScreenshotAsTexture();
string screenshotBase64 = Convert.ToBase64String(screenshot.EncodeToPNG());
var bytes = Convert.FromBase64String(screenshotBase64);
using (var imageScreenshot = new FileStream(PathFileScreenshot, FileMode.Create))
{
imageScreenshot.Write(bytes, 0, bytes.Length);
imageScreenshot.Flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment