Created
April 25, 2021 21:56
-
-
Save bobbyg603/5aff7992f94046928780e00b2b491d6f to your computer and use it in GitHub Desktop.
In memory screenshot in Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private byte[] CaptureInMemoryPngScreenshot() | |
{ | |
// TODO BG the example calls Destory on texture, do we need to do that? | |
var texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); | |
texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); | |
texture.Apply(); | |
return texture.EncodeToPNG(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment