Skip to content

Instantly share code, notes, and snippets.

@openroomxyz
Created April 6, 2020 11:21
Show Gist options
  • Save openroomxyz/fac200d1a88c01f174b607a27a98a953 to your computer and use it in GitHub Desktop.
Save openroomxyz/fac200d1a88c01f174b607a27a98a953 to your computer and use it in GitHub Desktop.
Unity : How to convert Render Texture into Texture2d?
private static Texture2D toTexture2D(RenderTexture rTex)
{
int widht = rTex.width;
int height = rTex.height;
Texture2D tex = new Texture2D(widht, height, TextureFormat.RGB24, false);
RenderTexture.active = rTex;
tex.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0);
tex.Apply();
return tex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment