I’m using RenderTexture to take screenshots in my Unity game.
I have successfully managed to draw the Camera contents to the target RenderTexture and grab part of the RenderTexture’s contents (i.e.: A Region Of Interest) using the code below:
RenderTexture currentActiveRT =RenderTexture.active;
var renderTex =newRenderTexture((int)renderTexSize.x,(int)renderTexSize.y,24,RenderTextureFormat.ARGB32);
CameraScreenshot.targetTexture = renderTex;CameraScreenshot.gameObject.SetActive(true);CameraScreenshot.Render();
RenderTexture.active = renderTex;
// 4. Create the final output Texture, which will have the the ROI drawn in the final size.var tex =newTexture2D((int)screenshotSize.x,(int)screenshotSize.y,TextureFormat.RGB24,false);
tex.ReadPixels(fROI,0,0,true);
// 5. Restore context and release resources.
RenderTexture.active = currentActiveRT;
Everything works as expected on both the Unity Editor and the iPad device, however, on my iPhone 5S device the final output gets wrong because a different region of the RenderTexture is used. After some debugging I realised that on both Editor and iPad the origin of the RenderTexturecoordinate system is bottom-left (upwards) but on the iPhone it is top-left (downwards).
Does anyone know how can I fix that?
Original S.O. thread: ios - Unity RenderTexture coordinate system origin is bottom-left on iPad, but top-left on iPhone 5S - Stack Overflow
