1
我使用RenderTexture在我的Unity遊戲中拍攝屏幕截圖。Unity RenderTexture座標系原點在iPad上是左下角,但左上角是iPhone 5S
我已經成功地設法相機內容提請各RenderTexture
的內容,目標RenderTexture
,抓住部分(即:感興趣區域):
RenderTexture currentActiveRT = RenderTexture.active;
var renderTex = new RenderTexture ((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 = new Texture2D ((int)screenshotSize.x, (int)screenshotSize.y, TextureFormat.RGB24, false);
tex.ReadPixels (fROI, 0, 0, true);
// 5. Restore context and release resources.
RenderTexture.active = currentActiveRT;
一切正常使用下面的代碼但是在Unity Editor和iPad設備上,在我的iPhone 5S設備上,最終輸出會出錯,因爲使用了RenderTexture
的不同區域。經過一些調試後,我意識到在編輯器和iPad上,RenderTexture
座標系的原點是左下角(向上),但在iPhone上它是左上角(向下)。
有誰知道我該如何解決這個問題?