From b6fa293cd358b21d224948d51778714cc932d844 Mon Sep 17 00:00:00 2001 From: dsarno Date: Wed, 14 Jan 2026 20:14:44 -0800 Subject: [PATCH] Guard refresh wait nudge during compile (#558) --- MCPForUnity/Editor/Tools/RefreshUnity.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MCPForUnity/Editor/Tools/RefreshUnity.cs b/MCPForUnity/Editor/Tools/RefreshUnity.cs index f331641..577ae7d 100644 --- a/MCPForUnity/Editor/Tools/RefreshUnity.cs +++ b/MCPForUnity/Editor/Tools/RefreshUnity.cs @@ -94,7 +94,9 @@ namespace MCPForUnity.Editor.Tools { try { - await WaitForUnityReadyAsync(TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds)).ConfigureAwait(true); + await WaitForUnityReadyAsync( + TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds), + allowNudge: !compileRequested).ConfigureAwait(true); } catch (TimeoutException) { @@ -126,7 +128,7 @@ namespace MCPForUnity.Editor.Tools }); } - private static Task WaitForUnityReadyAsync(TimeSpan timeout) + private static Task WaitForUnityReadyAsync(TimeSpan timeout, bool allowNudge) { var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var start = DateTime.UtcNow; @@ -165,8 +167,11 @@ namespace MCPForUnity.Editor.Tools } EditorApplication.update += Tick; - // Nudge Unity to pump once in case update is throttled. - try { EditorApplication.QueuePlayerLoopUpdate(); } catch { } + if (allowNudge) + { + // Nudge Unity to pump once in case update is throttled. + try { EditorApplication.QueuePlayerLoopUpdate(); } catch { } + } return tcs.Task; } }