I’m trying to use Texture2D.ReadPixels to grab a screenshot. As it is, my code works fine in the editor, but I just get a bunch of black pixels when run on the ipod. Is ReadPixels unsupported/broken on the iphone version, or am I just doing it wrong?
Here is my current code (C#):
public IEnumerator ScreenCapture()
{
yield return new WaitForEndOfFrame();
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false);
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0 );
tex.Apply();
byte[] bytes = tex.EncodeToPNG();
// Do stuff with bytes
Destroy (tex);
}
Thanks for the help!