diff --git a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/ScreenshotCapture.cs b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/ScreenshotCapture.cs index 63a038b5..f025905f 100644 --- a/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/ScreenshotCapture.cs +++ b/src/gg.regression.unity.bots/Runtime/Scripts/StateRecorder/ScreenshotCapture.cs @@ -314,8 +314,7 @@ private IEnumerator UpdateGPUData(int frame, Action<(byte[], int, int)?> onCompl var screenWidth = Screen.width; var screenHeight = Screen.height; - if (_screenShotTexture == null || _screenShotTexture.width != screenWidth || - _screenShotTexture.height != screenHeight) + if (_screenShotTexture == null || _screenShotTexture.width != screenWidth || _screenShotTexture.height != screenHeight) { if (_screenShotTexture != null) { @@ -326,8 +325,7 @@ private IEnumerator UpdateGPUData(int frame, Action<(byte[], int, int)?> onCompl { // why Metal defaults to B8G8R8A8_SRGB and thus flips the colors.. who knows.. // this setting stops it from spamming log errors - _screenShotTexture = new RenderTexture(screenWidth, screenHeight, 0, - GraphicsFormat.R8G8B8A8_SRGB); + _screenShotTexture = new RenderTexture(screenWidth, screenHeight, 0, GraphicsFormat.R8G8B8A8_SRGB); } else { @@ -340,15 +338,12 @@ private IEnumerator UpdateGPUData(int frame, Action<(byte[], int, int)?> onCompl try { ScreenCapture.CaptureScreenshotIntoRenderTexture(_screenShotTexture); - var readbackRequest = AsyncGPUReadback.Request(_screenShotTexture, 0, - GraphicsFormat.R8G8B8A8_SRGB, request => + var readbackRequest = AsyncGPUReadback.Request(_screenShotTexture, 0, GraphicsFormat.R8G8B8A8_SRGB, request => { if (!request.hasError) { var pixels = request.GetData(); - var copyBuffer = - _copyBuffer - .Value; // uses a threadlocal to avoid re-allocating this on every readback + var copyBuffer = _copyBuffer.Value; // uses a threadlocal to avoid re-allocating this on every readback if (SystemInfo.graphicsUVStartsAtTop) { // the pixels from the GPU are upside down, we need to reverse this for it to be right side up @@ -357,30 +352,24 @@ private IEnumerator UpdateGPUData(int frame, Action<(byte[], int, int)?> onCompl { // swap rows // bottom row to buffer - NativeArray.Copy(pixels, i * screenWidth, copyBuffer, 0, - screenWidth); + NativeArray.Copy(pixels, i * screenWidth, copyBuffer, 0, screenWidth); // top row to bottom - NativeArray.Copy(pixels, (screenHeight - i - 1) * screenWidth, - pixels, i * screenWidth, screenWidth); + NativeArray.Copy(pixels, (screenHeight - i - 1) * screenWidth, pixels, i * screenWidth, screenWidth); // buffer to top row - NativeArray.Copy(copyBuffer, 0, pixels, - (screenHeight - i - 1) * screenWidth, screenWidth); + NativeArray.Copy(copyBuffer, 0, pixels, (screenHeight - i - 1) * screenWidth, screenWidth); } } //else.. we're fine - var imageOutput = ImageConversion.EncodeNativeArrayToJPG(pixels, theGraphicsFormat, - (uint)screenWidth, (uint)screenHeight); + var imageOutput = ImageConversion.EncodeNativeArrayToJPG(pixels, theGraphicsFormat, (uint)screenWidth, (uint)screenHeight); RGDebug.LogDebug($"ScreenshotCapture - Captured screenshot for frame # {frame}"); AddFrame(frame, (imageOutput.ToArray(), screenWidth, screenHeight)); } else { - RGDebug.LogWarning( - $"ScreenshotCapture - Error capturing screenshot for frame # {frame}"); + RGDebug.LogWarning($"ScreenshotCapture - Error capturing screenshot for frame # {frame}"); AddFrame(frame, null); } - HandleCompletedActionCallbacks(); }); // update from null to the real request @@ -389,8 +378,7 @@ private IEnumerator UpdateGPUData(int frame, Action<(byte[], int, int)?> onCompl } catch (Exception e) { - RGDebug.LogWarning( - $"ScreenshotCapture - Exception starting to capture screenshot for frame # {frame} - {e.Message}"); + RGDebug.LogWarning($"ScreenshotCapture - Exception starting to capture screenshot for frame # {frame} - {e.Message}"); } }