Guard refresh wait nudge during compile (#558)
parent
3f08ac0e43
commit
b6fa293cd3
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue