Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created February 25, 2020 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimmduh/c6f27f219c3decc32e73330c54326d3c to your computer and use it in GitHub Desktop.
Save dimmduh/c6f27f219c3decc32e73330c54326d3c to your computer and use it in GitHub Desktop.
unity - convert Render Texture To 2D Texture
private Texture2D RenderTextureTo2DTexture(RenderTexture rt)
{
var texture = new Texture2D(rt.width, rt.height, rt.graphicsFormat, 0, TextureCreationFlags.None);
RenderTexture.active = rt;
texture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
texture.Apply();
RenderTexture.active = null;
return texture;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment