IEnumerator CoroutineScreenShot(System.Action action)
{
//ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.
yield return new WaitForEndOfFrame();
byte[] data = CaptureScreenshot();
CacheUtil.WriteSync(ScreenshotPath,data);
if(action!=null)
action();
yield break;
}
/// <summary>
/// 截圖
/// </summary>
public void SahreCaptureScreenshot()
{
Dg.Log("SaveCaptureScreenshot:", ScreenshotPath);
StartCoroutine(CoroutineScreenShot(() => {
}));
}
屏幕截圖時(shí)需要在協(xié)程中執(zhí)行,且必須有yield return new WaitForEndOfFrame();,否則報(bào)錯(cuò):ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.