- Home /
Texture2D.ReadPixels not working on iOS (GL error 0x0502)
I am capturing the screen using the Texture2D.ReadPixels method but when I capture the pixels, gl throws error 0x0502 indicating an invalid GL operation has occurred.
Code (C#):
Texture2D tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
Rect src = new Rect(0f, 0f, Screen.width, Screen.height);
tex.ReadPixels(src, 0, 0, false); //Error is not thrown if this line is commented out
Actual error:
OpenGLES error 0x0502 in /[WORKING DIRECTORY]/Classes/iPhone_GlesSupport.cpp:189
Any ideas what is causing this? This is a real head scratcher for me and so far I haven't been able to turn up any similar issue on this site or through googling.
Answer by kirpigiller · May 23, 2012 at 05:08 AM
Thanks for the link, I'm sure that was also an issue but it doesn't seem to have fixed anything.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071824im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Test game on iPhone 1 Answer
Serialize and deserialize class to Byte[] on IOS 2 Answers
Using System.Reflection with iOS 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers