- Home /
ReadPixels returns RGBA(0,0,0,0)
Long story short:
Texture2D textureA;
public Texture2D textureB;
textureA = new Texture2D(textureB.width, textureB.height);
textureA.ReadPixels(new Rect(0, 0, textureB.width, textureB.height), 0, 0);
textureA.Apply();
For testing, I visualized the texture via DrawTexture. Works in the editor and when I build the game for Windows 64bit, the texture has the correct dimensions but it is blank. I read about a bug that I shouldn't use Anti-Aliasing but that doesn't help me.
Thanks for help, folks!
I don't know but perhaps your render texture format differ between standalone and editor?
This function works on ARGB32 and RGB24 texture formats, when render target is of a similar format too (e.g. usual 32 or 16 bit render texture). Reading from a HDR render target (ARGBFloat or ARGBHalf render texture formats) into HDR texture formats (RGBAFloat or RGBAHalf) is supported too.
Perhaps you could try a different texture format?
I tested it with a render texture and with a PNG file as Texture2D with the same results
Your answer
Follow this Question
Related Questions
Why is ReadPixels on my RenderTexture creating a pure gray texture? 1 Answer
Use RenderTexture as ShaderResource in DX11 native plug-in 1 Answer
Raycast project to texture at runtime 1 Answer
Alternative for Graphics.CopyTexture() ? 2 Answers
Can a Texture2D be created at runtime from a snapshot of a RenderTexture? 3 Answers