Created
April 6, 2020 11:21
-
-
Save openroomxyz/fac200d1a88c01f174b607a27a98a953 to your computer and use it in GitHub Desktop.
Unity : How to convert Render Texture into Texture2d?
This file contains hidden or 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 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