Editor View
Overview
Editor View allows you to directly control the Unity/Tuanjie Editor from within the AI conversation interface. It is not a 3D WebGL scene viewer, but a tool execution and result display system — it communicates in real-time with a running Unity Editor via TCP bridging, presenting tool call results as cards in the chat interface.
Supported Engines
- Unity
- Tuanjie
Requirements & Installation
Prerequisites
| Item | Requirement |
|---|---|
| Node.js | ≥ 20.19.0 |
| Unity Editor | Must be running with a project open |
| Bridge Package | cn.tuanjie.codely.bridge |
Install Unity Bridge Package
Refer to Connect Unity/Tuanjie Editor
Project Detection
The system automatically detects whether the current directory is a Unity project, checking:
- Whether Unity project identifier files exist in the project root
- Whether the
cn.tuanjie.codely.bridgeMCP package is installed - Engine type (Unity or Tuanjie) and version number
Connection Status & Indicators
Status Types
| Status | Meaning | Icon Color |
|---|---|---|
connected | Connected to Unity Editor | 🟢 Green |
connecting | Connecting | 🟡 Yellow |
not-connected | Not connected | - |
reconnecting | Reconnecting | 🟡 Yellow |
error | Connection error | 🔴 Red |
Screenshot Feature
Supported Camera Types
| Camera | Description |
|---|---|
| Game View | Game view screenshot |
| Scene View | Scene view screenshot |
| Main Camera | Main camera screenshot |
| Custom Camera | Specified camera screenshot |
Screenshot Card UI
After a screenshot is captured, a screenshot card appears in the chat interface:
- Displays the screenshot image (
object-fit: contain, max height 400px) - Labels the camera view source (Game View / Scene View)
- Shows spinning animation while loading
- Shows error state if screenshot fails
- Supports click to enlarge
Additional Options
- Custom resolution
- Orthographic projection mode
Take a screenshot of the Game View
Take a 1920x1080 screenshot from the Scene View
Troubleshooting
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Status shows "Not connected" | Unity Editor not running or bridge package not installed | Start Unity Editor and confirm bridge package is installed |
| Frequent disconnections after connecting | TCP port occupied or firewall blocking | Check if port 25916 is available, check firewall rules |
| Tool calls unresponsive | Unity Editor is compiling/loading | Wait for compilation to finish and retry |
| Script modification errors | Compilation failure | Check console error logs and fix code |
| Screenshot capture failed | Game View not open or camera doesn't exist | Ensure the target view/camera is available |
| Asset generation stuck at progress | Generator error or network issue | Check Unity console errors, confirm network connection |
Best Practices
- Read before write: Read current state before modifying to avoid overwriting important changes
- Prefer idempotent operations: Use
ensure_*operations instead ofadd/createto avoid duplicates - Compile verification: Always check compilation results after modifying scripts
- Save scene: Save the scene before baking, playing, or completing important operations
- Console separation: Record
sinceTokenbefore risky operations to only focus on new logs - Avoid write during Play Mode: Don't modify the scene in Play Mode unless explicitly debugging Play behavior
Reset Connection
If the connection is abnormal, try:
- Click the Unity toggle button to disable and re-enable
- Re-import the bridge package in the Unity Editor
- Restart the Unity Editor
Appendix: Tool Output Card Types
The UnityToolOutput component renders different cards based on the tool and operation return data types:
| Output Type | Rendered Form |
|---|---|
| Console logs | Log entry list |
| GameObject info | Object detail card |
| Component list | Component property table |
| Data grid | Table format |
| Warning | Yellow alert bar |
| Error | Red error card |
| Screenshot | Image display |
| Asset preview | Scaled preview image + metadata |
| JSON data | Formatted code block |