diff --git a/MCPForUnity/Runtime/Helpers/ScreenshotUtility.cs b/MCPForUnity/Runtime/Helpers/ScreenshotUtility.cs index a49346ade..79b6a6160 100644 --- a/MCPForUnity/Runtime/Helpers/ScreenshotUtility.cs +++ b/MCPForUnity/Runtime/Helpers/ScreenshotUtility.cs @@ -186,9 +186,20 @@ private static Texture2D CaptureCompositedAfterFrame(int superSize, int timeoutS result = tex; done = true; }); - for (int i = 0; i < timeoutSteps && !done; i++) + // Step() pauses play mode as a side effect; restore the prior state so a screenshot + // doesn't leave a running game paused (an already-paused game stays paused). + bool wasPaused = UnityEditor.EditorApplication.isPaused; + try + { + for (int i = 0; i < timeoutSteps && !done; i++) + { + UnityEditor.EditorApplication.Step(); + } + } + finally { - UnityEditor.EditorApplication.Step(); + if (!wasPaused) + UnityEditor.EditorApplication.isPaused = false; } callerReturned = true; return result;