I would like to introduce you my approach in communication between AI agents and Unity Editor - Code Mode for Unity, which is completely free for now and represents my research results in agentic LLM usage in game development.
GitHub repository
Sorry, no ads-like cool video with claude building simple scene from primitives for you today – I have no time for video editing and my goal is to build real tool for real projects, not yet another MCP toy. You can easily try it yourself in a few simple steps, though.
What is Code Mode?
In contrast to rigid MCP tool defenitions, which always kept in LLM context, CodeMode is an approach which helps AI to call tools in the most familiar way - by writing JavaScript code based on TypeScript defenitions of tools. This helps AI to keep token consumption low, implement loops and chained calls for complex tasks, organize output in compact form and reuse output from different existing servers and endpoints in one JavaScript execution context, isolating LLM context from unnecessary data.
How it can be used with Unity Editor?
Code Mode for Unity runs an HTTP server inside the editor that exposes scene manipulation, asset management and property inspection as structured tool calls via UTCP Protocol - letting AI agents build, inspect, and modify Unity projects the same way a developer would through the UI.
These tools are combined in UTCP Code Mode environment to achieve maximum performance and token efficiency for AI agents, letting them call the tools in isolated JS sandbox.
Flexible tools architecture
Tools exposed in Code Mode are arranged in clear, straightforward and domain-specific manner, allowing LLM to easily select specific tools for exact task. On development of this toolset I was inspired with actual Unity Editor UI, because this is real, existing and long-tested user experience which helps millions of users get things done every day. Here is quick overview of tool categories and how they are related to Editor’s UI:
| Category | Tools | Purpose |
|---|---|---|
| Scene | GameObjectGetTree, GameObjectGetAtPath, GameObjectCreate, GameObjectCreatePrimitive, GameObjectOperate |
Navigate and build scene hierarchy |
| Components | GameObjectComponentsGet, GameObjectComponentAdd, GameObjectComponentRemove, GameObjectGetAvailableComponentTypes |
Attach, remove, and discover components |
| Inspector | InspectorGetInstanceDefinition, InspectorGetInstanceProperties, InspectorSetInstanceProperties |
Introspect types and read/write properties |
| Assets | AssetGetTree, AssetGetAtPath, AssetCreate, AssetImport, AssetOperate, AssetGetPreview |
Browse, create, and manage project assets |
| Editor | EditorOperate, EditorGetLogs, EditorGetScenePreview |
Control editor state and capture previews |
| Settings | SettingsGetDefinition, SettingsGetProperties, SettingsSetProperties |
Read and modify project settings |
Current goals
This is an early release, which already helped me in my development process, and for now I just want to share it with the community and see how much interest this approach can get. Personally I see a lot of potential in it, and it would be great to hear your thoughts and maybe even see if it helps you in integration of AI in your development pipeline.
Please, read more at github page, test this thing out, look at the actual implementation, write feedback and reviews - I would really appreciate any sort of contribution!
You can always ask me a question or two by DM in LinkedIn
