Skip to content

Instantly share code, notes, and snippets.

Forked from AlexanderDzhoganov/DebugUtil.cs
Created March 26, 2021 11:52
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Dump RenderTexture to PNG in Unity
public static class DebugUtil
public static void DumpRenderTexture(RenderTexture rt, string pngOutPath)
var oldRT =;
var tex = new Texture2D(rt.width, rt.height); = rt;
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
File.WriteAllBytes(pngOutPath, tex.EncodeToPNG()); = oldRT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment