Created
February 25, 2020 18:26
-
-
Save dimmduh/c6f27f219c3decc32e73330c54326d3c to your computer and use it in GitHub Desktop.
unity - convert Render Texture To 2D Texture
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 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