-
使用API:https://docs.unity3d.com/ScriptReference/Texture2D.ReadPixels.html
-
http://answers.unity3d.com/questions/9969/convert-a-rendertexture-to-a-texture2d.html
The trick here is to create a new Texture2D, and then use the ReadPixels method to read the pixels from the RenderTexture to the Texture2D, like this:
RenderTexture.active=myRenderTexture;
myTexture2D.ReadPixels(newRect(0,0,myRenderTexture.width,myRenderTexture.height),0,0);
myTexture2D.Apply();
myTexture2D.getPixel(......);
原理就是使用 Texture2D.ReadPixels 将当前(RenderTexture.active)纹理读取到 Texture2D中。
网友评论