SIGN IN SIGN UP

fix: dispatch WebSocket messages via update-drained queue instead of delayCall

McpUnitySocketHandler.OnMessage marshalled each request onto the main thread
with `EditorApplication.delayCall += ...` from the WebSocketSharp background
thread. delayCall is a plain static delegate; a `+=` from a foreign thread is
not reliably observed or drained by the main thread while the Editor is idle in
the background. As a result, requests that arrived while Unity was not the
foreground application were never executed and the MCP client timed out (a
common complaint when driving Unity from an AI client in another window).

Add McpMainThreadDispatcher: a ConcurrentQueue<Action> drained from
EditorApplication.update (which keeps firing in the background), and enqueue the
handler into it instead of using delayCall. No cross-thread delegate mutation,
so requests are delivered regardless of Editor focus.

Note: for delivery while fully backgrounded on macOS, the editor loop must keep
ticking - disabling App Nap for the Editor process helps
(`defaults write com.unity3d.UnityEditor5.x NSAppSleepDisabled -bool YES`).
F
Feetschaa committed
1e9a8fb069fac76dad3fd7ddf8f82b9f558d5588
Parent: c35f184
Committed by Feetschaa <philipp_schoeler@hotmail.com> on 7/7/2026, 7:15:00 AM