Guard refresh wait nudge during compile (#558)

main
dsarno 2026-01-14 20:14:44 -08:00 committed by GitHub
parent 3f08ac0e43
commit b6fa293cd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 4 deletions

View File

@ -94,7 +94,9 @@ namespace MCPForUnity.Editor.Tools
{ {
try try
{ {
await WaitForUnityReadyAsync(TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds)).ConfigureAwait(true); await WaitForUnityReadyAsync(
TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds),
allowNudge: !compileRequested).ConfigureAwait(true);
} }
catch (TimeoutException) 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<bool>(TaskCreationOptions.RunContinuationsAsynchronously); var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var start = DateTime.UtcNow; var start = DateTime.UtcNow;
@ -165,8 +167,11 @@ namespace MCPForUnity.Editor.Tools
} }
EditorApplication.update += Tick; EditorApplication.update += Tick;
if (allowNudge)
{
// Nudge Unity to pump once in case update is throttled. // Nudge Unity to pump once in case update is throttled.
try { EditorApplication.QueuePlayerLoopUpdate(); } catch { } try { EditorApplication.QueuePlayerLoopUpdate(); } catch { }
}
return tcs.Task; return tcs.Task;
} }
} }