Bug Report: EditorApplication.isCompiling False Positive in Play Mode
Summary
EditorApplication.isCompiling returns true even when Unity is not actually compiling, causing MCP tools to incorrectly return "error": "busy", "reason": "compiling" in Play mode.
Environment
- Unity Version: 2022.3.x
- MCP for Unity Version: Latest (git)
- OS: macOS
Steps to Reproduce
- Enter Play mode in Unity Editor
- Use MCP client (Cursor) to call tools like
find_gameobjects or manage_scene
- Observe intermittent
"error": "busy", "reason": "compiling" errors even though Unity is not compiling
Root Cause Analysis
Through debugging, we found that EditorApplication.isCompiling can return true in Play mode even when CompilationPipeline.isCompiling (via reflection) returns false.
Debug Evidence
// Unity reports compiling but actually not compiling:
{
"editorAppIsCompiling": true, // ← False positive!
"pipelineIsCompiling": false, // ← Actually not compiling
"possibleFalsePositive": true
}
Affected Code
Editor/Services/EditorStateCache.cs uses EditorApplication.isCompiling directly:
// Line 292
bool isCompiling = EditorApplication.isCompiling;
Proposed Fix
Add a helper method that double-checks with CompilationPipeline.isCompiling in Play mode:
private static bool GetActualIsCompiling()
{
// First check EditorApplication.isCompiling
if (!EditorApplication.isCompiling)
{
return false;
}
// In Play mode, EditorApplication.isCompiling can have false positives
// Double-check with CompilationPipeline.isCompiling via reflection
if (EditorApplication.isPlaying)
{
try
{
Type pipeline = Type.GetType("UnityEditor.Compilation.CompilationPipeline, UnityEditor");
var prop = pipeline?.GetProperty("isCompiling", BindingFlags.Public | BindingFlags.Static);
if (prop != null)
{
return (bool)prop.GetValue(null);
}
}
catch { }
}
return EditorApplication.isCompiling;
}
Then replace:
bool isCompiling = EditorApplication.isCompiling;
with:
bool isCompiling = GetActualIsCompiling();
Workaround
Users can manually patch the local package until this is fixed upstream.
Additional Context
This issue appears to be related to Unity's internal state management during Play mode, where EditorApplication.isCompiling may not accurately reflect the actual compilation state.
Bug Report:
EditorApplication.isCompilingFalse Positive in Play ModeSummary
EditorApplication.isCompilingreturnstrueeven when Unity is not actually compiling, causing MCP tools to incorrectly return"error": "busy", "reason": "compiling"in Play mode.Environment
Steps to Reproduce
find_gameobjectsormanage_scene"error": "busy", "reason": "compiling"errors even though Unity is not compilingRoot Cause Analysis
Through debugging, we found that
EditorApplication.isCompilingcan returntruein Play mode even whenCompilationPipeline.isCompiling(via reflection) returnsfalse.Debug Evidence
Affected Code
Editor/Services/EditorStateCache.csusesEditorApplication.isCompilingdirectly:Proposed Fix
Add a helper method that double-checks with
CompilationPipeline.isCompilingin Play mode:Then replace:
with:
Workaround
Users can manually patch the local package until this is fixed upstream.
Additional Context
This issue appears to be related to Unity's internal state management during Play mode, where
EditorApplication.isCompilingmay not accurately reflect the actual compilation state.