-
Notifications
You must be signed in to change notification settings - Fork 842
Description
Problem
When an AI agent (e.g. in Cursor) edits a script and then needs to play the game or run other Unity operations, it must wait for Unity to finish recompiling. Today there is no dedicated way to “wait until compilation is done,” so agents tend to:
- Use fixed sleeps (e.g.
sleep 5,sleep 3) after script changes, which is slow and brittle (sometimes compile is done in 1s, sometimes longer). - Poll the
editor_stateresource forcompilation.is_compilingin a loop, which works but is verbose and easy to get wrong.
In a real “play → read console → fix error → re-verify” workflow, this led to roughly ~12 seconds of sleep in a single run (play wait, recompile wait, play-again wait), making the loop feel slow even when the actual fix was simple.
Proposed solution
Add a wait_for_compilation capability so the agent can explicitly wait for compilation (and domain reload) to finish instead of guessing with sleeps or implementing custom polling.
Concretely:
manage_editor(action="wait_for_compilation")- Server-side only (no new Unity C# API required).
- Uses existing
editor_state/ compilation state and the existing “wait for editor ready” logic (e.g.wait_for_editor_ready/wait_for_no_compile) to block until compilation is done. - Optional
timeout(e.g. default 30s, max 120s). - Returns as soon as compilation is already done, or after it finishes within the timeout.
This keeps the workflow clear for the agent:
manage_script(action="update", ...)— apply script changemanage_editor(action="wait_for_compilation")— wait until Unity is readymanage_editor(action="play")— enter play moderead_console(...)— check for errors
No play_and_check or other new high-level action is required for this step; the main win is removing the need for long, fixed sleeps and ad-hoc polling.
References
- Here is my chat log
