Tuanjie AI Doubles Unity Development Efficiency
This document provides detailed instructions on how to use Codely CLI and its powerful Unity Tools toolkit to directly manipulate the Unity Editor through natural language commands, achieving automation and intelligence in the game development workflow, thereby doubling development efficiency.
1. Why Does Unity Development Need AI?
In Unity game development, developers often encounter the following problems:
-
Time-Consuming Repetitive Operations: Basic operations such as creating game objects, adding components, and adjusting properties require repeated clicks in the editor. A lot of time goes into repetitive tasks.
-
Difficult Code Writing: Even for simple functions, you need to write complete C# code. Beginners don't know where to start, and experienced developers still need to frequently consult documentation.
-
Tedious Debugging Process: When runtime errors occur, you need to check the console, locate the code, modify the script, and recompile. The entire process needs to be repeated many times.
-
Scene Setup Overhead: Tasks such as batch creating objects, configuring materials, and setting physics properties require a lot of manual operations, which is both time-consuming and error-prone.
-
Inconvenient Project Management: There are many scene files and resources scattered everywhere, lacking convenient viewing and management methods.
-
High Team Collaboration Learning Costs: New members need to spend a long time becoming familiar with the project structure, resource organization methods, and code standards.
Codely CLI can help solve these problems. It supports describing what you want to do in natural language, and then automatically operates the Unity Editor to complete tasks, making Unity development simpler and more efficient.
2. Tuanjie AI Unity Tools Core Capabilities
Tuanjie AI provides 13 professional tools for Unity development, covering the complete development process from editor control to asset management:
Core Tools
| Tool Category | Tool Name | Core Capability | Typical Scenarios |
|---|---|---|---|
| Editor Control | unity_editor | Playback control, compilation management, window management, tags and layers | Debugging, compilation, project configuration |
| Scene Management | unity_scene | Create/load/save scenes, query hierarchy | Scene switching, level design |
| Object Management | unity_gameobject | Create/modify/delete objects, component operations | Scene setup, prefab creation |
| Log Diagnosis | unity_console | Read console, filter errors | Bug debugging, log analysis |
| Script Development | unity_script | Create/edit/validate scripts | Code generation, quick modifications |
| Asset Management | unity_asset | Create materials/textures, search, batch operations | Asset organization, material configuration |
| Rendering Pipeline | unity_shader | Shader management, SRP detection | Rendering optimization, pipeline adaptation |
| Dependency Management | unity_package | Install/remove packages | Dependency management, feature extension |
| Scene Baking | unity_bake | NavMesh/light baking | AI navigation, GI optimization |
| UI Development | unity_ui_toolkit | UXML/USS management | UI system building |
| Automation | unity_menu | Execute menu commands | Batch processing, tool integration |
| Visualization | unity_screenshot | Multi-camera screenshots | Documentation, testing records |
| Extensibility | execute_custom_tool | Custom tool execution | Project-specific functionality |
Core Advantages
✅ Natural Language Interaction: No need to memorize complex APIs, operate Unity by speaking
✅ Batch Automation: Complete operations that originally required dozens of clicks with a single command
✅ Intelligent Error Diagnosis: Automatically analyze console errors and provide fix suggestions
✅ Seamless Integration: Direct communication with Unity Editor with real-time feedback
✅ High Extensibility: Supports custom tools, adaptable to any project needs
3. Practical Guide: Unity Project from Scratch
Next, we will demonstrate through a complete practical case how to use Tuanjie AI to create a simple 3D game scene from scratch, experiencing the AI-assisted development process.
Practical Goals
Create a 3D scene containing the following elements:
- Walkable ground platform
- Controllable player character
- Patrolling enemy AI
- Collectible items
- Complete navigation mesh and lighting
1. Environment Preparation
1.1 Install Codely CLI
Execute the following command in the terminal to install Codely CLI:
# macOS/Linux
curl -fsSL https://codesearch-plugins.tos-cn-shanghai.volces.com/codely-cli/install.sh | bash
# Windows (PowerShell)
irm https://codesearch-plugins.tos-cn-shanghai.volces.com/codely-cli/install.ps1 | iex
After installation, verify the installation:
codely --version
1.2 Login to Tuanjie AI
Codely CLI supports login via Unity ID account (Tuanjie AI OAuth authentication).
When using for the first time, start interactive mode in the project directory:
# Start Tuanjie AI interactive mode
codely
Enter in interactive mode:
/auth
Codely CLI will automatically open the browser and navigate to the authentication page. Follow the prompts to complete login. After successful authentication, your credentials will be cached locally, and you won't need to login again for subsequent use.
2. Project Initialization
2.1 Create Unity Project
Open Unity Hub and create a new 3D (URP) project named TuanjieAIDemo.
2.2 Install Codely Bridge Plugin
In the Unity project directory, start Codely CLI interactive mode:
# Enter Unity project directory
cd /path/to/your/unity/project
# Start Tuanjie AI interactive mode
codely
In interactive mode, enter the following commands in sequence:
# After install, click unity, wait for unity to download and install the plugin
/upm install
/upm refresh
/upm status
After installation, /upm status will display the plugin's installation status and version information. Confirm successful plugin installation:
- Status shows
cn.tuanjie.codely.bridgeis installed - Open Unity Editor and check if the Tools-Codely Bridge menu appears in the menu bar
- You can see the Codely Bridge package in Package Manager
2.3 Generate Project Summary
Enter in Tuanjie AI interactive mode:
Analyze the current Unity project and generate a project summary document CODELY.md
Tuanjie AI will automatically scan the project and generate a document containing the following information:
- Project type (3D/2D)
- Rendering pipeline (URP/HDRP/Built-in)
- Installed packages
- Scene list
- Scripting define symbols
3. Scene Setup: Create Game World in One Sentence
The traditional method requires dozens of clicks in the editor. Now in interactive mode, you only need one command:
Help me build a 3D game scene:
1. Create a 10x10 Plane as ground, named Ground
2. Add MeshCollider component to the ground
3. Create a Capsule as player, position at (0, 1, 0), named Player
4. Add Rigidbody and CapsuleCollider to Player
5. Create 3 Cubes as enemies, randomly distributed in the scene, named Enemy1, Enemy2, Enemy3
6. Add Enemy tag to all enemies
7. Create a Directional Light
8. Create a Main Camera, position at (0, 5, -10), facing the center of the scene
9. Save the scene as GameLevel
Execution Process: Tuanjie AI will automatically:
- Call
unity_scene.createto create the scene - Call
unity_gameobject.createto create objects one by one - Call
unity_gameobject.add_componentto add components - Call
unity_editor.ensure_tagto ensure tags exist - Call
unity_scene.saveto save the scene
The entire process is completed automatically without manual operation!
4. Materials and Beautification: Intelligent Asset Management
4.1 Create Materials
Create three materials:
1. PlayerMat.mat - Blue material, metallic 0.5, smoothness 0.8
2. EnemyMat.mat - Red material, metallic 0.3, smoothness 0.6
3. GroundMat.mat - Gray material, using Standard Shader
4.2 Apply Materials
Assign PlayerMat to Player's MeshRenderer,
Assign EnemyMat to all objects with Enemy tag,
Assign GroundMat to Ground
Tuanjie AI will automatically:
- Call
unity_asset.createto create materials - Call
unity_gameobject.set_component_propertyto set material references
5. Script Development: AI-Assisted Programming
5.1 Create Player Controller
Create a PlayerController script that implements the following functionality:
1. Use WASD to control movement, movement speed 5
2. Use mouse to control view rotation
3. Press space to jump, jump force 5
4. Include complete comments and error handling
5.2 Create Enemy AI
Create EnemyAI script to implement patrol functionality:
1. Patrol back and forth between two points
2. Patrol speed 2
3. Wait for 1 second after reaching target point
4. Use Gizmos to visualize patrol path
5.3 Auto-Compile and Validate
Clear console, compile all scripts, wait for compilation to complete, and if there are errors please tell me in detail
Tuanjie AI will:
- Call
unity_console.clearto clear logs - Call
unity_editor.start_compilation_pipelineto compile - Call
unity_editor.wait_for_compileto wait for completion - Call
unity_console.getto read errors - Automatically analyze and provide fix suggestions
6. Component Configuration: Batch Intelligent Operations
6.1 Add Scripts to Objects
Add PlayerController component to Player,
Add EnemyAI component to all objects with Enemy tag
6.2 Configure Component Properties
Set Player's PlayerController.moveSpeed to 8,
Set all Enemies' EnemyAI.patrolSpeed to 3
7. Lighting Configuration
Configure scene lighting:
Set Directional Light intensity to 1.5, color to light yellow
8. Camera Configuration
The camera is a key component for rendering the scene and needs to be configured correctly to see the game scene.
8.1 Configure Main Camera
Configure Main Camera:
1. Set position to (0, 5, -10)
2. Set rotation to (15, 0, 0), making it slightly look downward
3. Set Field of View to 60
4. Set background color to light blue
8.2 Create Follow Camera (Optional)
If you need the camera to follow the player, you can create a camera controller:
Create a CameraController script:
1. Camera follows target object (Player)
2. Maintain relative position (0, 5, -10)
3. Smooth following using Vector3.Lerp
4. Support mouse wheel to adjust distance
Then add the script to Main Camera:
Add CameraController component to Main Camera,
Set target to Player object
9. Debugging and Testing
9.1 Test Run
Start playing the game, pause after 15 seconds, read all errors and warnings from console
9.2 Error Analysis
If there are errors, Tuanjie AI can automatically analyze:
Analyze errors in the console, locate specific code lines, and provide fix suggestions
10. Project Organization
10.1 Asset Organization
Search for all material files and move them to Assets/Materials folder
10.2 Create Prefabs
Save Player as prefab Assets/Prefabs/Player.prefab,
Also save all Enemy objects as independent prefabs
4. Summary
With Codely CLI and Unity Tools, Unity developers can:
✅ Say Goodbye to Repetitive Labor: Natural language commands replace hundreds of click operations
✅ Accelerate Script Development: AI-assisted generation of high-quality, commented code
✅ Intelligent Error Diagnosis: Automatically analyze problems and provide fix suggestions
✅ Batch Automation: Complete batch asset management and scene configuration with a single command
✅ Rapid Prototype Development: Quickly validate game ideas and mechanics
✅ 10-30x Efficiency Improvement: Reduce development time from hours to minutes
Whether for independent developers rapidly validating game ideas or large teams collaborating on complex projects, Tuanjie AI can become a powerful assistant to boost Unity development efficiency.