unity-mcp icon indicating copy to clipboard operation
unity-mcp copied to clipboard

manage_menu_item execute does not run when Unity Editor is inactive

Open toro-ponz opened this issue 1 year ago • 4 comments

Description

When executing a menu command (manage_menu_item execute), the action does not run if the Unity Editor is inactive. The command is only executed once the Unity Editor becomes active.

Environment:

Unity version: 6.2 (6000.2.5f1) unity-mcp version: ~v3.4.0~ main(https://github.com/CoplayDev/unity-mcp/commit/6e72b333092ec099e1712784d2289547cc6db1a1) OS: Windows & WSL2 (Claude Code)

Notes

It is unclear whether this behavior is due to a Unity Editor setting or is caused by the implementation of unity-mcp.

toro-ponz avatar Sep 21 '25 10:09 toro-ponz

I suspect that this issue is likely caused by the use of delayCall here. https://github.com/CoplayDev/unity-mcp/blob/6e72b333092ec099e1712784d2289547cc6db1a1/UnityMcpBridge/Editor/Tools/MenuItems/MenuItemExecutor.cs#L41C17-L41C44

toro-ponz avatar Sep 21 '25 10:09 toro-ponz

Thanks @toro-ponz. I think removing the delayCall may force the editor to take focus. It might be an annoying UX, but I'll test and confirm if that works. Feel free to test as well if you have to the time to sooner.

msanatan avatar Sep 22 '25 15:09 msanatan

@toro-ponz it was the delayCall as you expected. One thing to note, the actions were run for me, but just delayed (true to the function's name lol). As I mentioned it earlier removing it does bring the editor window into focus. It will be included in the next release

msanatan avatar Sep 25 '25 19:09 msanatan

This is in the latest release: https://github.com/CoplayDev/unity-mcp/releases/tag/v4.0.0

msanatan avatar Sep 26 '25 23:09 msanatan