Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions MCPForUnity/Editor/Tools/RefreshUnity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public static async Task<object> HandleCommand(JObject @params)
{
try
{
await WaitForUnityReadyAsync(TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds)).ConfigureAwait(true);
await WaitForUnityReadyAsync(
TimeSpan.FromSeconds(DefaultWaitTimeoutSeconds),
allowNudge: !compileRequested).ConfigureAwait(true);
}
catch (TimeoutException)
{
Expand Down Expand Up @@ -126,7 +128,7 @@ public static async Task<object> HandleCommand(JObject @params)
});
}

private static Task WaitForUnityReadyAsync(TimeSpan timeout)
private static Task WaitForUnityReadyAsync(TimeSpan timeout, bool allowNudge)
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var start = DateTime.UtcNow;
Expand Down Expand Up @@ -165,8 +167,11 @@ void Tick()
}

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;
}
}
Expand Down