I need to take screenshot and hold it in memory so later I can serialise it in save file with all the other information I need to save. We’re using Unity 2019.3.0a8 and as documentation says for taking screenshots there is class ScreenCapture for which I wasn’t able to find any information except for Unity Scripting API. So I have two questions.
First, as documentation says I need to wait till the end of frame rendering and the proper way of doing so is (taken from ScreenCapture.CaptureScreenshotAsTexture)
yield return new WaitForEndOfFrame();
var texture = ScreenCapture.CaptureScreenshotAsTexture();
// do something with texture
However if I’m using yield return, I can’t have neither return value for the method nor ref parameter thus I can’t use the screenshot inside the method in which I call
StartCoroutine(TakeScreenshot());. I was thinking of using async/await but it allows me to wait only for some amount of seconds and not exactly till the end of frame. How can I wait for end of frame rendering without using yield?
Second question here.