I want to capture the screen with any active post-process applied, but none of the post-process are included in the texture. is anyone able to walk me through the code for generating a screen capture with post-process applied to it? currently, my code looks like this:
///
/// Method for capturing the screen with post process applied
///
private IEnumerator CaptureScreenshotWithPostProcess()
{
RenderTexture renderTexture = new RenderTexture(Screen.width, Screen.height, 32);
Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
Camera camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent();
RenderTexture.active = renderTexture;
camera.targetTexture = renderTexture;
yield return new WaitForEndOfFrame();
Rect rect = new Rect(0, 0, Screen.width, Screen.height);
Vector2 pivot = new Vector2(Screen.width / 2, Screen.height / 2);
texture.ReadPixels(rect, 0, 0, false);
texture.Apply();
m_MenuBackground = Sprite.Create(texture, rect, pivot, 180f);
camera.targetTexture = null;
RenderTexture.active = null;
}
↧