Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:19:28 +08:00
commit 1da7b24c8e
254 changed files with 43797 additions and 0 deletions

View File

@@ -0,0 +1,324 @@
# Unity Editor Toolkit - Command Reference
Unity Editor를 제어할 수 있는 500+ 명령어 로드맵입니다.
**Current Status**: Phase 2 - 42 commands implemented
## Quick Reference
```bash
# Basic usage
cd <unity-project-root> && node .unity-websocket/uw <command> [options]
# Show all available commands
cd <unity-project-root> && node .unity-websocket/uw --help
# Show help for specific command
cd <unity-project-root> && node .unity-websocket/uw <command> --help
```
## 📖 Documentation by Category
### ✅ Implemented (Phase 1+)
| Category | Commands | Documentation |
|----------|----------|---------------|
| **Connection & Status** | 1 command | [COMMANDS_CONNECTION_STATUS.md](./COMMANDS_CONNECTION_STATUS.md) |
| **GameObject & Hierarchy** | 8 commands | [COMMANDS_GAMEOBJECT_HIERARCHY.md](./COMMANDS_GAMEOBJECT_HIERARCHY.md) |
| **Transform** | 4 commands | [COMMANDS_TRANSFORM.md](./COMMANDS_TRANSFORM.md) |
| **Component** | 10 commands | [COMMANDS_COMPONENT.md](./COMMANDS_COMPONENT.md) |
| **Scene Management** | 7 commands | [COMMANDS_SCENE.md](./COMMANDS_SCENE.md) |
| **Asset Database & Editor** | 3 commands | [COMMANDS_EDITOR.md](./COMMANDS_EDITOR.md) |
| **Console & Logging** | 2 commands | [COMMANDS_CONSOLE.md](./COMMANDS_CONSOLE.md) |
| **EditorPrefs Management** | 6 commands | [COMMANDS_PREFS.md](./COMMANDS_PREFS.md) |
| **Wait Commands** | 4 commands | [COMMANDS_WAIT.md](./COMMANDS_WAIT.md) |
| **Chain Commands** | 2 commands | [COMMANDS_CHAIN.md](./COMMANDS_CHAIN.md) |
| **Menu Execution** | 2 commands | [COMMANDS_MENU.md](./COMMANDS_MENU.md) |
| **Asset Management (ScriptableObject)** | 9 commands | [COMMANDS_ASSET.md](./COMMANDS_ASSET.md) |
| **Prefab** | 12 commands | [COMMANDS_PREFAB.md](./COMMANDS_PREFAB.md) |
### 🔄 Coming Soon (Phase 2+)
| Category | Status |
|----------|--------|
| **Material & Rendering** | 🔄 25+ commands planned |
| **Animation** | 🔄 20+ commands planned |
| **Physics** | 🔄 20+ commands planned |
| **Lighting** | 🔄 15+ commands planned |
| **Camera** | 🔄 15+ commands planned |
| **Audio** | 🔄 15+ commands planned |
| **Navigation & AI** | 🔄 15+ commands planned |
| **Particle System** | 🔄 15+ commands planned |
| **Timeline** | 🔄 10+ commands planned |
| **Build & Player** | 🔄 15+ commands planned |
| **Project Settings** | 🔄 20+ commands planned |
| **Package Manager** | 🔄 10+ commands planned |
| **Version Control** | 🔄 10+ commands planned |
| **Profiler & Performance** | 🔄 15+ commands planned |
| **Test Runner** | 🔄 10+ commands planned |
| **Input System** | 🔄 10+ commands planned |
| **UI Toolkit** | 🔄 10+ commands planned |
| **Editor Window & UI** | 🔄 10+ commands planned |
| **Utility Commands** | 🔄 20+ commands planned |
---
## Quick Command Examples
### Connection & Status
```bash
cd <unity-project-root> && node .unity-websocket/uw status [--port <port>] [--json]
```
### GameObject & Hierarchy
```bash
# Find GameObject by name or path
cd <unity-project-root> && node .unity-websocket/uw go find <name> [--json]
# Create GameObject
cd <unity-project-root> && node .unity-websocket/uw go create <name> [--parent <parent>] [--json]
# Destroy GameObject
cd <unity-project-root> && node .unity-websocket/uw go destroy <name> [--json]
# Set active state
cd <unity-project-root> && node .unity-websocket/uw go set-active <name> <true|false> [--json]
# Set/remove parent
cd <unity-project-root> && node .unity-websocket/uw go set-parent <name> [parent] [--json]
# Get parent info
cd <unity-project-root> && node .unity-websocket/uw go get-parent <name> [--json]
# Get children
cd <unity-project-root> && node .unity-websocket/uw go get-children <name> [--recursive] [--json]
# View hierarchy tree
cd <unity-project-root> && node .unity-websocket/uw hierarchy [--root-only] [--include-inactive] [--json]
```
### Transform
```bash
# Get transform information
cd <unity-project-root> && node .unity-websocket/uw tf get <name> [--json]
# Set position (x,y,z)
cd <unity-project-root> && node .unity-websocket/uw tf set-position <name> <x,y,z> [--json]
# Set rotation (Euler angles in degrees)
cd <unity-project-root> && node .unity-websocket/uw tf set-rotation <name> <x,y,z> [--json]
# Set scale
cd <unity-project-root> && node .unity-websocket/uw tf set-scale <name> <x,y,z> [--json]
```
### Component Management
```bash
# List components on GameObject
cd <unity-project-root> && node .unity-websocket/uw comp list <gameobject> [--include-disabled] [--json]
# Add component to GameObject
cd <unity-project-root> && node .unity-websocket/uw comp add <gameobject> <component-type> [--json]
# Remove component from GameObject
cd <unity-project-root> && node .unity-websocket/uw comp remove <gameobject> <component-type> [--json]
# Enable/Disable component
cd <unity-project-root> && node .unity-websocket/uw comp enable <gameobject> <component-type> [--json]
cd <unity-project-root> && node .unity-websocket/uw comp disable <gameobject> <component-type> [--json]
# Get component properties
cd <unity-project-root> && node .unity-websocket/uw comp get <gameobject> <component-type> [property] [--json]
# Set component property
cd <unity-project-root> && node .unity-websocket/uw comp set <gameobject> <component-type> <property> <value> [--json]
# Inspect component (show all properties)
cd <unity-project-root> && node .unity-websocket/uw comp inspect <gameobject> <component-type> [--json]
# Move component order
cd <unity-project-root> && node .unity-websocket/uw comp move-up <gameobject> <component-type> [--json]
cd <unity-project-root> && node .unity-websocket/uw comp move-down <gameobject> <component-type> [--json]
# Copy component between GameObjects
cd <unity-project-root> && node .unity-websocket/uw comp copy <source> <component-type> <target> [--json]
```
### Scene Management
```bash
# Get current scene info
cd <unity-project-root> && node .unity-websocket/uw scene current [--json]
# List all loaded scenes
cd <unity-project-root> && node .unity-websocket/uw scene list [--json]
# Load scene
cd <unity-project-root> && node .unity-websocket/uw scene load <name> [--additive] [--json]
# Create new scene
cd <unity-project-root> && node .unity-websocket/uw scene new [--empty] [--additive] [--json]
# Save scene
cd <unity-project-root> && node .unity-websocket/uw scene save [path] [--scene <name>] [--json]
# Unload scene
cd <unity-project-root> && node .unity-websocket/uw scene unload <name> [--remove] [--json]
# Set active scene (multi-scene editing)
cd <unity-project-root> && node .unity-websocket/uw scene set-active <name> [--json]
```
### Asset Database & Editor
```bash
# Refresh AssetDatabase
cd <unity-project-root> && node .unity-websocket/uw editor refresh [--json]
# Recompile scripts
cd <unity-project-root> && node .unity-websocket/uw editor recompile [--json]
# Reimport assets
cd <unity-project-root> && node .unity-websocket/uw editor reimport <path> [--json]
```
### Console & Logging
```bash
# Get console logs
cd <unity-project-root> && node .unity-websocket/uw console logs [--count <n>] [--errors-only] [--warnings] [--json]
# Clear console
cd <unity-project-root> && node .unity-websocket/uw console clear [--json]
```
### EditorPrefs Management
```bash
# Get EditorPrefs value
cd <unity-project-root> && node .unity-websocket/uw prefs get <key> [-t <type>] [-d <default>] [--json]
# Set EditorPrefs value
cd <unity-project-root> && node .unity-websocket/uw prefs set <key> <value> [-t <type>] [--json]
# Delete EditorPrefs key
cd <unity-project-root> && node .unity-websocket/uw prefs delete <key> [--json]
# Check if key exists
cd <unity-project-root> && node .unity-websocket/uw prefs has <key> [--json]
# Delete all EditorPrefs keys
cd <unity-project-root> && node .unity-websocket/uw prefs delete-all [--json]
# List all EditorPrefs keys
cd <unity-project-root> && node .unity-websocket/uw prefs list [--json]
```
### Wait Commands
```bash
# Wait for compilation to complete
cd <unity-project-root> && node .unity-websocket/uw wait compile [--timeout <ms>] [--json]
# Wait for play mode changes
cd <unity-project-root> && node .unity-websocket/uw wait playmode <enter|exit|pause> [--timeout <ms>] [--json]
# Sleep for duration
cd <unity-project-root> && node .unity-websocket/uw wait sleep <seconds> [--timeout <ms>] [--json]
# Wait for scene to finish loading (play mode only)
cd <unity-project-root> && node .unity-websocket/uw wait scene [--timeout <ms>] [--json]
```
### Chain Commands
```bash
# Execute commands from JSON file
cd <unity-project-root> && node .unity-websocket/uw chain execute <file> [--continue-on-error] [--timeout <ms>] [--json]
# Execute commands inline
cd <unity-project-root> && node .unity-websocket/uw chain exec <commands...> [--continue-on-error] [--timeout <ms>] [--json]
# Example: inline commands with parameters
cd <unity-project-root> && node .unity-websocket/uw chain exec \
"GameObject.Create:name=Player" \
"GameObject.SetActive:instanceId=123,active=true" \
--continue-on-error
```
### Prefab Management
```bash
# Instantiate prefab
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate <path> [--name <name>] [--position <x,y,z>] [--json]
# Create prefab from scene object
cd <unity-project-root> && node .unity-websocket/uw prefab create <gameobject> <path> [--overwrite] [--json]
# Unpack prefab instance
cd <unity-project-root> && node .unity-websocket/uw prefab unpack <gameobject> [--completely] [--json]
# Apply/Revert prefab overrides
cd <unity-project-root> && node .unity-websocket/uw prefab apply <gameobject> [--json]
cd <unity-project-root> && node .unity-websocket/uw prefab revert <gameobject> [--json]
# Create prefab variant
cd <unity-project-root> && node .unity-websocket/uw prefab variant <sourcePath> <variantPath> [--json]
# Get prefab overrides
cd <unity-project-root> && node .unity-websocket/uw prefab overrides <gameobject> [--json]
# Get source prefab info
cd <unity-project-root> && node .unity-websocket/uw prefab source <gameobject> [--json]
# Check if prefab instance
cd <unity-project-root> && node .unity-websocket/uw prefab is-instance <gameobject> [--json]
# Open/Close prefab edit mode
cd <unity-project-root> && node .unity-websocket/uw prefab open <path> [--json]
cd <unity-project-root> && node .unity-websocket/uw prefab close [--json]
# List prefabs in folder
cd <unity-project-root> && node .unity-websocket/uw prefab list [--path <path>] [--json]
```
---
## Development Roadmap
### Phase 1 (Current) - Core Foundation ✅
- **30 commands** across 8 categories
- GameObject manipulation, Transform control, Scene management
- Console logging, Editor utilities, EditorPrefs
- Wait conditions, Command chaining
### Phase 2 - Component & Material System 🔄
- **~140+ commands**
- Component management (Add, Remove, Configure)
- Material system (Colors, Textures, Shaders)
- Prefab system (Instantiate, Create, Override)
- Asset Database (Search, Import, Dependencies)
### Phase 3 - Animation & Physics 🔄
- **~170+ commands**
- Animation system (Animator, Curves, Events)
- Physics system (Rigidbody, Collider, Raycast)
- Lighting system (Lights, Lightmaps, Probes)
- Camera system (FOV, Viewport, Screenshots)
### Phase 4 - Advanced Features 🔄
- **~100+ commands**
- Audio system (AudioSource, Mixer, 3D Audio)
- Navigation & AI (NavMesh, Agents, Obstacles)
- Particle system (Emission, Modules, Simulation)
- Timeline (Playable Director, Tracks, Clips)
### Phase 5 - Build & Tools 🔄
- **~100+ commands**
- Build pipeline (Build, Player Settings, Platforms)
- Project Settings (Quality, Physics, Input, Graphics)
- Package Manager (Install, Update, Remove)
- Version Control (Git, Plastic SCM)
- Profiler & Performance (CPU, GPU, Memory)
- Test Runner (Unit Tests, Code Coverage)
- Input System (Actions, Bindings, Devices)
- UI Toolkit (Visual Elements, USS, UXML)
---
**Total Roadmap**: 500+ commands across 25 categories
For detailed command documentation with all options and examples, see the category-specific documentation files linked above.

View File

@@ -0,0 +1,549 @@
# Asset Management Commands (ScriptableObject)
Unity ScriptableObject 에셋을 생성하고 조회하며 수정할 수 있는 명령어입니다. 배열/리스트 완전 지원 및 모든 필드 타입을 지원합니다.
## Available Commands
| Command | Description |
|---------|-------------|
| `asset list-types` | List available ScriptableObject types |
| `asset create-so` | Create a new ScriptableObject asset |
| `asset get-fields` | Get fields of a ScriptableObject (supports array expansion) |
| `asset set-field` | Set a field value (supports array index notation) |
| `asset inspect` | Inspect a ScriptableObject with full metadata |
| `asset add-element` | Add an element to an array/list field |
| `asset remove-element` | Remove an element from an array/list field |
| `asset get-element` | Get a specific array element |
| `asset clear-array` | Clear all elements from an array/list field |
---
## asset list-types
프로젝트에서 사용 가능한 ScriptableObject 타입을 조회합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset list-types [options]
```
### Options
- `--filter <pattern>` - Filter types by pattern (supports * wildcard)
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# List all ScriptableObject types
cd <unity-project-root> && node .unity-websocket/uw asset list-types
# Filter by pattern
cd <unity-project-root> && node .unity-websocket/uw asset list-types --filter "*Config*"
cd <unity-project-root> && node .unity-websocket/uw asset list-types --filter "Game*"
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset list-types --json
```
---
## asset create-so
새로운 ScriptableObject 에셋을 생성합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset create-so <typeName> <path> [options]
```
### Parameters
- `<typeName>` - ScriptableObject type name (full or short name)
- `<path>` - Asset path (e.g., "Assets/Config/game.asset")
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Create ScriptableObject by short name
cd <unity-project-root> && node .unity-websocket/uw asset create-so GameConfig "Assets/Config/game.asset"
# Create ScriptableObject by full name
cd <unity-project-root> && node .unity-websocket/uw asset create-so "MyGame.GameConfig" "Config/settings"
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset create-so ItemData "Items/sword.asset" --json
```
### Notes
- Path automatically gets "Assets/" prefix if not present
- Path automatically gets ".asset" extension if not present
- Parent directories are created automatically
- Type name can be short (e.g., "GameConfig") or full (e.g., "MyGame.GameConfig")
---
## asset get-fields
ScriptableObject의 필드를 조회합니다. 배열 확장 옵션 지원.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset get-fields <path> [options]
```
### Parameters
- `<path>` - Asset path (e.g., "Assets/Config/game.asset")
### Options
- `--expand` - Expand array/list elements
- `--depth <n>` - Max depth for nested expansion (default: 3)
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Get basic fields
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Assets/Config/game.asset"
# Expand arrays
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Config/game.asset" --expand
# Expand with custom depth
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Config/game.asset" --expand --depth 5
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Config/game.asset" --json
```
### Response (without --expand)
```
✓ Fields for MyGame.GameConfig (Assets/Config/game.asset):
Player Health (playerHealth)
Type: Integer
Value: 100
Items (items)
Type: Generic [Array: 3]
Element Type: Generic
Value: [Array: 3 elements]
```
### Response (with --expand)
```
✓ Fields for MyGame.GameConfig (Assets/Config/game.asset):
Items (items)
Type: Generic [Array: 3]
Element Type: Generic
Value: [Array: 3 elements]
Element 0 ([0])
Type: Generic
Value: [Object: 2 fields]
Item Name (itemName)
Type: String
Value: Sword
Item Count (itemCount)
Type: Integer
Value: 5
```
---
## asset set-field
ScriptableObject의 필드 값을 설정합니다. 배열 인덱스 표기법 지원.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset set-field <path> <fieldName> <value> [options]
```
### Parameters
- `<path>` - Asset path
- `<fieldName>` - Field name or path (supports array index: `items[0]`, `items[2].name`)
- `<value>` - New value (format depends on field type)
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Field Name Patterns
```bash
# Simple field
"playerHealth"
# Array element (by index)
"items[0]"
# Nested field in array element
"items[0].itemName"
"items[2].count"
# Multi-level nesting
"enemies[1].stats.health"
```
### Value Formats by Type
| Type | Format | Example |
|------|--------|---------|
| Integer | `"10"` | `"100"` |
| Float | `"1.5"` | `"3.14"` |
| String | `"text"` | `"Sword"` |
| Boolean | `"true"` or `"false"` | `"true"` |
| Enum | `"EnumValue"` or `"0"` | `"Active"` |
| Vector2 | `"x,y"` | `"1.0,2.0"` |
| Vector3 | `"x,y,z"` | `"1.0,2.0,3.0"` |
| Vector4 | `"x,y,z,w"` | `"1,2,3,4"` |
| Color | `"r,g,b,a"` | `"1,0,0,1"` |
| Quaternion | `"x,y,z,w"` | `"0,0,0,1"` |
| Rect | `"x,y,width,height"` | `"0,0,100,50"` |
| Bounds | `"centerX,Y,Z,sizeX,Y,Z"` | `"0,0,0,10,10,10"` |
| Vector2Int | `"x,y"` | `"10,20"` |
| Vector3Int | `"x,y,z"` | `"1,2,3"` |
| RectInt | `"x,y,width,height"` | `"0,0,100,50"` |
| BoundsInt | `"posX,Y,Z,sizeX,Y,Z"` | `"0,0,0,5,5,5"` |
| AnimationCurve | `"time:value;time:value"` | `"0:0;1:1"` |
| ObjectReference | `"Assets/path/to/asset"` | `"Assets/Prefabs/Player.prefab"` |
| ArraySize | `"3"` | Changes array size |
### Examples
```bash
# Set simple field
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "playerHealth" "100"
# Set array element
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "items[0]" "NewValue"
# Set nested field in array
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "items[0].itemName" "Sword"
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "items[2].count" "10"
# Set Vector3
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "spawnPosition" "10.5,0,5.2"
# Set Color
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "tintColor" "1,0,0,1"
# Set ObjectReference
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "playerPrefab" "Assets/Prefabs/Player.prefab"
# Change array size
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "items.Array.size" "5"
```
---
## asset inspect
ScriptableObject의 전체 메타데이터와 필드를 조회합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset inspect <path> [options]
```
### Parameters
- `<path>` - Asset path
### Options
- `--expand` - Expand array/list elements
- `--depth <n>` - Max depth for nested expansion (default: 3)
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Inspect asset
cd <unity-project-root> && node .unity-websocket/uw asset inspect "Assets/Config/game.asset"
# Inspect with array expansion
cd <unity-project-root> && node .unity-websocket/uw asset inspect "Config/game.asset" --expand
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset inspect "Config/game.asset" --json
```
---
## asset add-element
배열/리스트 필드에 새 요소를 추가합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset add-element <path> <fieldName> [options]
```
### Parameters
- `<path>` - Asset path
- `<fieldName>` - Array field name
### Options
- `--value <value>` - Initial value for the new element
- `--index <n>` - Insert position (-1 = end, default: -1)
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Add element at end
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "items"
# Add element with initial value
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "items" --value "NewItem"
# Add element at specific index
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "items" --index 0 --value "FirstItem"
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "enemies" --json
```
---
## asset remove-element
배열/리스트 필드에서 요소를 제거합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset remove-element <path> <fieldName> <index> [options]
```
### Parameters
- `<path>` - Asset path
- `<fieldName>` - Array field name
- `<index>` - Index of element to remove
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Remove first element
cd <unity-project-root> && node .unity-websocket/uw asset remove-element "Config/game.asset" "items" 0
# Remove last element (if array has 5 elements)
cd <unity-project-root> && node .unity-websocket/uw asset remove-element "Config/game.asset" "items" 4
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset remove-element "Config/game.asset" "enemies" 2 --json
```
---
## asset get-element
배열/리스트 필드의 특정 요소를 조회합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset get-element <path> <fieldName> <index> [options]
```
### Parameters
- `<path>` - Asset path
- `<fieldName>` - Array field name
- `<index>` - Index of element to get
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Get first element
cd <unity-project-root> && node .unity-websocket/uw asset get-element "Config/game.asset" "items" 0
# Get specific element
cd <unity-project-root> && node .unity-websocket/uw asset get-element "Config/game.asset" "enemies" 2
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset get-element "Config/game.asset" "items" 0 --json
```
---
## asset clear-array
배열/리스트 필드의 모든 요소를 제거합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw asset clear-array <path> <fieldName> [options]
```
### Parameters
- `<path>` - Asset path
- `<fieldName>` - Array field name
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout (default: 30000)
### Examples
```bash
# Clear array
cd <unity-project-root> && node .unity-websocket/uw asset clear-array "Config/game.asset" "items"
# JSON output
cd <unity-project-root> && node .unity-websocket/uw asset clear-array "Config/game.asset" "enemies" --json
```
---
## Workflow Examples
### 1. Create and Configure ScriptableObject
```bash
# Step 1: List available types
cd <unity-project-root> && node .unity-websocket/uw asset list-types --filter "*Config*"
# Step 2: Create new ScriptableObject
cd <unity-project-root> && node .unity-websocket/uw asset create-so GameConfig "Assets/Config/game.asset"
# Step 3: View fields
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Assets/Config/game.asset"
# Step 4: Set field values
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Assets/Config/game.asset" "playerHealth" "100"
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Assets/Config/game.asset" "playerName" "Hero"
```
### 2. Manage Array/List Fields
```bash
# View array
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Config/game.asset" --expand
# Add elements
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "items" --value "Sword"
cd <unity-project-root> && node .unity-websocket/uw asset add-element "Config/game.asset" "items" --value "Shield"
# Modify array element
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "items[0]" "LegendarySword"
# Remove element
cd <unity-project-root> && node .unity-websocket/uw asset remove-element "Config/game.asset" "items" 1
# Clear all
cd <unity-project-root> && node .unity-websocket/uw asset clear-array "Config/game.asset" "items"
```
### 3. Work with Nested Objects
```bash
# View nested structure
cd <unity-project-root> && node .unity-websocket/uw asset get-fields "Config/game.asset" --expand --depth 5
# Modify nested field
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "player.stats.health" "100"
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "enemies[0].name" "Goblin"
cd <unity-project-root> && node .unity-websocket/uw asset set-field "Config/game.asset" "enemies[0].stats.damage" "15"
```
---
## Supported Field Types
All Unity SerializedPropertyType values are supported:
- **Numeric**: Integer, Float, Boolean, Character, LayerMask
- **Vectors**: Vector2, Vector3, Vector4, Vector2Int, Vector3Int
- **Geometry**: Rect, RectInt, Bounds, BoundsInt, Quaternion
- **Graphics**: Color, AnimationCurve, Gradient (read-only)
- **References**: ObjectReference, ExposedReference
- **Special**: Enum, String, Hash128, ArraySize
- **Complex**: Generic (nested objects), ManagedReference
---
## Error Handling
### Asset Not Found
```
Error: ScriptableObject not found at: Assets/Config/missing.asset
```
**Solution**: Check asset path and ensure asset exists
### Type Not Found
```
Error: ScriptableObject type not found: InvalidType
```
**Solution**: Use `asset list-types` to find valid type names
### Field Not Found
```
Error: Field not found: invalidField
```
**Solution**: Use `asset get-fields` to see available fields
### Array Index Out of Range
```
Error: Index 10 out of range (0-4)
```
**Solution**: Check array size with `asset get-fields` or `asset get-element`
### Invalid Value Format
```
Error: Cannot convert '1.5' to integer
```
**Solution**: Check value format for the field type
---
## Best Practices
1. **Type Discovery**: Use `list-types` before `create-so`
2. **Field Inspection**: Use `get-fields --expand` to see structure
3. **Array Index**: Always check array size before accessing elements
4. **Nested Paths**: Use dot notation for nested objects: `items[0].name`
5. **Undo Support**: All modifications support Unity's Undo system
6. **Batch Operations**: Combine multiple `set-field` calls for efficiency
7. **JSON Output**: Use `--json` for programmatic parsing
8. **Error Handling**: Always check response for success/error status

View File

@@ -0,0 +1,329 @@
# Chain Commands Reference
Execute multiple Unity commands sequentially with error handling.
## Command Format
```bash
cd <unity-project-root>
node .unity-websocket/uw.js chain <subcommand> [options]
```
## Subcommands
### chain execute
Execute commands from a JSON file.
**Usage:**
```bash
node .unity-websocket/uw.js chain execute <file> [options]
```
**Arguments:**
- `<file>` - Path to JSON file containing commands
**Options:**
- `--json` - Output in JSON format
- `--stop-on-error` - Stop on first error (default: true)
- `--continue-on-error` - Continue execution even if a command fails
- `--timeout <ms>` - Timeout in milliseconds (default: 300000 = 5 minutes)
**JSON File Format:**
```json
[
{
"method": "Editor.Refresh",
"parameters": null
},
{
"method": "GameObject.Create",
"parameters": {
"name": "TestObject"
}
},
{
"method": "Console.Clear"
}
]
```
Or with wrapper:
```json
{
"commands": [
{ "method": "Editor.Refresh" },
{ "method": "Console.Clear" }
]
}
```
**Examples:**
```bash
# Execute commands from file
cd <unity-project-root> && node .unity-websocket/uw.js chain execute commands.json
# Continue on error
cd <unity-project-root> && node .unity-websocket/uw.js chain execute commands.json --continue-on-error
# JSON output
cd <unity-project-root> && node .unity-websocket/uw.js chain execute commands.json --json
```
---
### chain exec
Execute commands inline (without JSON file).
**Usage:**
```bash
node .unity-websocket/uw.js chain exec <commands...> [options]
```
**Arguments:**
- `<commands...>` - One or more commands in format: `method:param1=value1,param2=value2`
**Options:**
- `--json` - Output in JSON format
- `--stop-on-error` - Stop on first error (default: true)
- `--continue-on-error` - Continue execution even if a command fails
- `--timeout <ms>` - Timeout in milliseconds (default: 300000 = 5 minutes)
**Command Format:**
- Simple: `"Editor.Refresh"`
- With params: `"GameObject.Create:name=Test"`
- Multiple params: `"GameObject.SetActive:instanceId=123,active=true"`
**Parameter Parsing:**
- Strings: `name=MyObject`
- Numbers: `instanceId=123`
- Booleans: `active=true` or `active=false`
**Examples:**
```bash
# Simple commands
cd <unity-project-root> && node .unity-websocket/uw.js chain exec "Editor.Refresh" "Console.Clear"
# Commands with parameters
cd <unity-project-root> && node .unity-websocket/uw.js chain exec \
"GameObject.Create:name=Player" \
"GameObject.SetActive:instanceId=123,active=true"
# Continue on error
cd <unity-project-root> && node .unity-websocket/uw.js chain exec \
"Editor.Refresh" \
"GameObject.Find:path=InvalidPath" \
"Console.Clear" \
--continue-on-error
```
---
## Important Notes
### Supported Commands
Chain supports **immediate response** commands only. The following are **NOT supported**:
**Wait commands** (delayed response):
- `wait compile`
- `wait playmode`
- `wait sleep`
- `wait scene`
**All other commands** (immediate response):
- GameObject commands
- Transform commands
- Scene commands
- Console commands
- Editor commands
- Prefs commands
**Workaround for Wait:**
```bash
# Instead of chaining Wait commands:
cd <unity-project-root>
node .unity-websocket/uw.js wait compile
node .unity-websocket/uw.js chain exec "Editor.Refresh" "Console.Clear"
```
### Error Handling
**Stop on Error (default):**
```bash
# Stops at first failure
node .unity-websocket/uw.js chain exec "Editor.Refresh" "Invalid.Command" "Console.Clear"
# Result: Refresh succeeds, Invalid.Command fails, Console.Clear skipped
```
**Continue on Error:**
```bash
# Continues despite failures
node .unity-websocket/uw.js chain exec "Editor.Refresh" "Invalid.Command" "Console.Clear" --continue-on-error
# Result: Refresh succeeds, Invalid.Command fails, Console.Clear succeeds
```
### Timeout Behavior
- Default timeout: **300 seconds (5 minutes)** for entire chain
- Each command has its own execution time
- Total elapsed time is reported in response
---
## Output Format
### CLI Output
**Success:**
```
✓ Chain execution completed
Total commands: 3
Executed: 3
Total time: 0.015s
[1] ✓ Editor.Refresh (0.010s)
[2] ✓ GameObject.Create (0.003s)
[3] ✓ Console.Clear (0.002s)
```
**With Errors:**
```
✓ Chain execution completed
Total commands: 3
Executed: 2
Total time: 0.012s
[1] ✓ Editor.Refresh (0.010s)
[2] ✗ GameObject.Find (0.002s)
Error: GameObject not found: InvalidPath
```
### JSON Output
**Success:**
```json
{
"success": true,
"totalCommands": 3,
"executedCommands": 3,
"totalElapsed": 0.015,
"results": [
{
"index": 0,
"method": "Editor.Refresh",
"success": true,
"result": { "success": true, "message": "AssetDatabase refreshed" },
"elapsed": 0.010
},
{
"index": 1,
"method": "GameObject.Create",
"success": true,
"result": { "instanceId": 12345, "name": "TestObject" },
"elapsed": 0.003
},
{
"index": 2,
"method": "Console.Clear",
"success": true,
"result": { "success": true, "cleared": 10 },
"elapsed": 0.002
}
]
}
```
**With Errors:**
```json
{
"success": true,
"totalCommands": 3,
"executedCommands": 2,
"totalElapsed": 0.012,
"results": [
{
"index": 0,
"method": "Editor.Refresh",
"success": true,
"result": { "success": true, "message": "AssetDatabase refreshed" },
"elapsed": 0.010
},
{
"index": 1,
"method": "GameObject.Find",
"success": false,
"error": "GameObject not found: InvalidPath",
"elapsed": 0.002
}
]
}
```
---
## Common Workflows
### Cleanup Workflow
```json
{
"commands": [
{ "method": "Console.Clear" },
{ "method": "Editor.Refresh" },
{ "method": "Scene.Load", "parameters": { "name": "MainScene" } }
]
}
```
```bash
cd <unity-project-root> && node .unity-websocket/uw.js chain execute cleanup.json
```
### GameObject Batch Creation
```bash
cd <unity-project-root> && node .unity-websocket/uw.js chain exec \
"GameObject.Create:name=Player" \
"GameObject.Create:name=Enemy" \
"GameObject.Create:name=Pickup" \
"Console.Clear"
```
### Error-Tolerant Cleanup
```json
{
"commands": [
{ "method": "GameObject.Destroy", "parameters": { "path": "OldObject1" } },
{ "method": "GameObject.Destroy", "parameters": { "path": "OldObject2" } },
{ "method": "GameObject.Destroy", "parameters": { "path": "OldObject3" } },
{ "method": "Console.Clear" }
]
}
```
```bash
# Continue even if some objects don't exist
cd <unity-project-root> && node .unity-websocket/uw.js chain execute cleanup.json --continue-on-error
```
### CI/CD Pipeline
```bash
#!/bin/bash
cd /path/to/unity/project
# Cleanup
node .unity-websocket/uw.js chain exec "Console.Clear" "Editor.Refresh"
# Wait for compilation
node .unity-websocket/uw.js wait compile
# Run tests (example)
node .unity-websocket/uw.js chain exec \
"Scene.Load:name=TestScene" \
"GameObject.Find:path=TestRunner" \
"Console.Clear"
```

View File

@@ -0,0 +1,629 @@
# Unity Editor Toolkit - Component Commands
완전한 Component 조작 및 관리 명령어 레퍼런스입니다.
**Last Updated**: 2025-01-25
---
## comp list
GameObject의 모든 컴포넌트를 나열합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp list <gameobject> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로 (예: "Player" 또는 "Environment/Player")
```
**Options:**
```
--include-disabled 비활성 컴포넌트도 포함 (기본값: 활성 컴포넌트만 표시)
--type-only 컴포넌트 타입만 표시 (세부 정보 제외)
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Output Icons:**
```
● 활성 빌트인 컴포넌트
○ 비활성 컴포넌트
★ MonoBehaviour (커스텀 스크립트)
```
**Examples:**
```bash
# GameObject의 모든 활성 컴포넌트 나열
cd <unity-project-root> && node .unity-websocket/uw comp list "Player"
# 비활성 컴포넌트도 포함하여 나열
cd <unity-project-root> && node .unity-websocket/uw comp list "Enemy" --include-disabled
# 타입만 표시
cd <unity-project-root> && node .unity-websocket/uw comp list "Character" --type-only
# JSON 형식으로 출력
cd <unity-project-root> && node .unity-websocket/uw comp list "Player" --json
```
---
## comp add
GameObject에 컴포넌트를 추가합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp add <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 추가할 컴포넌트 타입 (예: Rigidbody, BoxCollider, AudioSource)
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Supported Component Types:**
- Unity Built-in: Rigidbody, Rigidbody2D, BoxCollider, SphereCollider, CapsuleCollider, MeshCollider, AudioSource, AudioListener, Camera, Light, etc.
- Physics: Rigidbody, Rigidbody2D, Joint, SpringJoint, HingeJoint, ConfigurableJoint, etc.
- Rendering: MeshRenderer, SkinnedMeshRenderer, SpriteRenderer, LineRenderer, TrailRenderer, etc.
- Audio: AudioSource, AudioListener, AudioReverbFilter, etc.
- Custom: 모든 MonoBehaviour 스크립트
**Examples:**
```bash
# Rigidbody 추가
cd <unity-project-root> && node .unity-websocket/uw comp add "Player" Rigidbody
# BoxCollider 추가
cd <unity-project-root> && node .unity-websocket/uw comp add "Enemy" BoxCollider
# 커스텀 스크립트 추가
cd <unity-project-root> && node .unity-websocket/uw comp add "Character" PlayerController
# JSON 형식으로 응답 받기
cd <unity-project-root> && node .unity-websocket/uw comp add "Item" Collider --json
```
**Important:**
- Transform 컴포넌트는 모든 GameObject에 자동으로 포함되므로 추가할 수 없습니다.
- 같은 타입의 컴포넌트가 이미 존재하면 중복 추가되지 않습니다.
---
## comp remove
GameObject에서 컴포넌트를 제거합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp remove <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 제거할 컴포넌트 타입
```
**Options:**
```
--force 확인 없이 제거
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 컴포넌트 제거
cd <unity-project-root> && node .unity-websocket/uw comp remove "Player" AudioSource
# Rigidbody 제거
cd <unity-project-root> && node .unity-websocket/uw comp remove "Enemy" Rigidbody
# 확인 없이 제거
cd <unity-project-root> && node .unity-websocket/uw comp remove "Temp" BoxCollider --force
```
**Important:**
- Transform은 필수 컴포넌트이므로 제거할 수 없습니다.
- Ctrl+Z (Undo)로 되돌릴 수 있습니다.
---
## comp enable
GameObject의 컴포넌트를 활성화합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp enable <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 활성화할 컴포넌트 타입
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# AudioSource 활성화
cd <unity-project-root> && node .unity-websocket/uw comp enable "Player" AudioSource
# 커스텀 스크립트 활성화
cd <unity-project-root> && node .unity-websocket/uw comp enable "Character" PlayerController
# JSON 응답
cd <unity-project-root> && node .unity-websocket/uw comp enable "Enemy" AIController --json
```
**Important:**
- Behaviour를 상속한 컴포넌트(MonoBehaviour, Renderer, AudioSource 등)만 활성화/비활성화 가능합니다.
---
## comp disable
GameObject의 컴포넌트를 비활성화합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp disable <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 비활성화할 컴포넌트 타입
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# AudioSource 비활성화
cd <unity-project-root> && node .unity-websocket/uw comp disable "Player" AudioSource
# 커스텀 스크립트 비활성화
cd <unity-project-root> && node .unity-websocket/uw comp disable "Enemy" EnemyAI
# 렌더러 비활성화
cd <unity-project-root> && node .unity-websocket/uw comp disable "Visual" MeshRenderer --json
```
**Important:**
- Behaviour를 상속한 컴포넌트만 비활성화 가능합니다.
- 게임 오브젝트가 비활성화되어 있으면 모든 컴포넌트가 자동으로 비활성 상태입니다.
---
## comp get
컴포넌트의 속성값을 조회합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp get <gameobject> <component> [property] [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 컴포넌트 타입
[property] 특정 속성 이름 (생략하면 모든 속성 표시)
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Rigidbody의 모든 속성 조회
cd <unity-project-root> && node .unity-websocket/uw comp get "Player" Rigidbody
# 특정 속성 값 조회
cd <unity-project-root> && node .unity-websocket/uw comp get "Player" Rigidbody mass
# Transform 위치 조회
cd <unity-project-root> && node .unity-websocket/uw comp get "Enemy" Transform localPosition
# JSON 형식으로 출력
cd <unity-project-root> && node .unity-websocket/uw comp get "Character" Camera fieldOfView --json
```
**Supported Property Types:**
- Primitive: int, float, bool, string
- Unity Types: Vector2, Vector3, Vector4, Color, Rect, Bounds
- Enum: 열거형 값
- Reference: 게임 오브젝트/에셋 참조
---
## comp set
컴포넌트의 속성값을 설정합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp set <gameobject> <component> <property> <value> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 컴포넌트 타입
<property> 속성 이름
<value> 새 값 (쉼표로 구분된 벡터, 또는 일반 값)
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Value Formats:**
```
Integer/Float: 123 또는 45.67
Boolean: true 또는 false
String: "Hello World" 또는 HelloWorld
Vector3: "1,2,3" (공백 없이)
Color: "1,0,0,1" (R,G,B,A)
Enum: 열거형 이름 (예: "Linear")
ObjectReference: "GameObjectName" 또는 "GameObject:Component" 또는 "Assets/path/to/asset.ext"
```
**ObjectReference Formats (컴포넌트/에셋 참조):**
| 형식 | 예시 | 설명 |
|------|------|------|
| `null` | `"null"` | 참조 해제 |
| `GameObject` | `"Player"` | GameObject 참조 |
| `GameObject:Component` | `"GameHUD:UnityEngine.UIElements.UIDocument"` | 컴포넌트 참조 |
| `Asset Path` | `"Assets/Materials/Red.mat"` | 에셋 참조 |
**⚠️ 중요: 컴포넌트 참조 시 전체 네임스페이스 필요**
```
✅ "GameHUD:UnityEngine.UIElements.UIDocument" (전체 네임스페이스)
❌ "GameHUD:UIDocument" (작동 안함)
```
**Examples:**
```bash
# Rigidbody mass 설정
cd <unity-project-root> && node .unity-websocket/uw comp set "Player" Rigidbody mass 2.5
# 중력 비활성화
cd <unity-project-root> && node .unity-websocket/uw comp set "Floating" Rigidbody useGravity false
# 위치 설정
cd <unity-project-root> && node .unity-websocket/uw comp set "Enemy" Transform localPosition "5,10,0"
# Camera FOV 설정
cd <unity-project-root> && node .unity-websocket/uw comp set "MainCamera" Camera fieldOfView 75
# 색상 설정 (R,G,B,A)
cd <unity-project-root> && node .unity-websocket/uw comp set "Material" SpriteRenderer color "1,0,0,1"
# Enum 값 설정
cd <unity-project-root> && node .unity-websocket/uw comp set "Collider" Rigidbody constraints "FreezeRotationZ"
# ObjectReference 설정 - GameObject 참조
cd <unity-project-root> && node .unity-websocket/uw comp set "Enemy" AIController target "Player"
# ObjectReference 설정 - 컴포넌트 참조 (전체 네임스페이스 필수)
cd <unity-project-root> && node .unity-websocket/uw comp set "HUD" GameView uiDocument "GameHUD:UnityEngine.UIElements.UIDocument"
# ObjectReference 설정 - 에셋 참조
cd <unity-project-root> && node .unity-websocket/uw comp set "Enemy" SpriteRenderer sprite "Assets/Sprites/Enemy.png"
# ObjectReference 설정 - 참조 해제
cd <unity-project-root> && node .unity-websocket/uw comp set "Item" Pickup targetObject "null"
```
**Important:**
- Ctrl+Z (Undo)로 되돌릴 수 있습니다.
- 변경 전 기존 값을 응답에 포함합니다.
---
## comp inspect
컴포넌트의 모든 속성과 상태를 표시합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp inspect <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 컴포넌트 타입
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Rigidbody 전체 검사
cd <unity-project-root> && node .unity-websocket/uw comp inspect "Player" Rigidbody
# Transform 검사
cd <unity-project-root> && node .unity-websocket/uw comp inspect "Enemy" Transform
# 커스텀 스크립트 검사
cd <unity-project-root> && node .unity-websocket/uw comp inspect "Character" PlayerController
# JSON으로 출력 및 파일 저장
cd <unity-project-root> && node .unity-websocket/uw comp inspect "Item" Collider --json > component.json
```
**Output Format:**
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ComponentName
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
● Type: Full.Type.Name
● Enabled: true
propertyName1 : PropertyType = value1
propertyName2 : PropertyType = value2
...
```
---
## comp move-up
컴포넌트를 컴포넌트 목록에서 위로 이동합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp move-up <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 이동할 컴포넌트 타입
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Rigidbody를 위로 이동
cd <unity-project-root> && node .unity-websocket/uw comp move-up "Player" Rigidbody
# BoxCollider를 위로 이동
cd <unity-project-root> && node .unity-websocket/uw comp move-up "Enemy" BoxCollider
# 먼저 목록 확인
cd <unity-project-root> && node .unity-websocket/uw comp list "Character"
# 그 다음 이동
cd <unity-project-root> && node .unity-websocket/uw comp move-up "Character" CustomScript
```
**Important:**
- Transform은 항상 첫 번째 위치에 고정되므로 이동할 수 없습니다.
- Inspector의 표시 순서가 변경됩니다.
- 일부 컴포넌트는 실행 순서에 영향을 받을 수 있습니다.
---
## comp move-down
컴포넌트를 컴포넌트 목록에서 아래로 이동합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp move-down <gameobject> <component> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<component> 이동할 컴포넌트 타입
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Rigidbody를 아래로 이동
cd <unity-project-root> && node .unity-websocket/uw comp move-down "Player" Rigidbody
# 컴포넌트 순서 재정렬
cd <unity-project-root> && node .unity-websocket/uw comp move-down "Character" AudioSource
cd <unity-project-root> && node .unity-websocket/uw comp move-down "Character" AudioSource
# 최종 결과 확인
cd <unity-project-root> && node .unity-websocket/uw comp list "Character"
```
**Important:**
- 이미 마지막 위치에 있으면 이동할 수 없습니다.
- Transform은 항상 첫 번째 위치입니다.
---
## comp copy
한 GameObject의 컴포넌트를 다른 GameObject로 복사합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw comp copy <source> <component> <target> [options]
```
**Arguments:**
```
<source> 원본 GameObject 이름 또는 경로
<component> 복사할 컴포넌트 타입
<target> 대상 GameObject 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Rigidbody 복사
cd <unity-project-root> && node .unity-websocket/uw comp copy "Player" Rigidbody "Enemy"
# 여러 컴포넌트 복사
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" BoxCollider "New"
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" Rigidbody "New"
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" AudioSource "New"
# 스크립트 복사
cd <unity-project-root> && node .unity-websocket/uw comp copy "Character" PlayerController "Character2"
# 결과 확인
cd <unity-project-root> && node .unity-websocket/uw comp list "New"
```
**Important:**
- 원본 컴포넌트의 모든 속성이 복사됩니다.
- 대상 GameObject에 같은 타입의 컴포넌트가 있으면 덮어쓰지 않고 새로 추가합니다.
- Ctrl+Z (Undo)로 되돌릴 수 있습니다.
---
## Tips & Best Practices
### 컴포넌트 순서 최적화
```bash
# 1. 목록으로 현재 순서 확인
cd <unity-project-root> && node .unity-websocket/uw comp list "Player"
# 2. 필요한 순서대로 정렬
cd <unity-project-root> && node .unity-websocket/uw comp move-up "Player" Rigidbody
cd <unity-project-root> && node .unity-websocket/uw comp move-up "Player" BoxCollider
# 3. 최종 확인
cd <unity-project-root> && node .unity-websocket/uw comp list "Player"
```
### GameObject 템플릿 만들기
```bash
# 1. 하나의 GameObject에 모든 컴포넌트 추가 및 설정
cd <unity-project-root> && node .unity-websocket/uw comp add "Template" Rigidbody
cd <unity-project-root> && node .unity-websocket/uw comp add "Template" BoxCollider
cd <unity-project-root> && node .unity-websocket/uw comp add "Template" AudioSource
cd <unity-project-root> && node .unity-websocket/uw comp set "Template" Rigidbody mass 2.0
# 2. 다른 GameObject들에 복사
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" Rigidbody "Object1"
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" BoxCollider "Object1"
cd <unity-project-root> && node .unity-websocket/uw comp copy "Template" AudioSource "Object1"
```
### 대량 설정 변경
```bash
# 여러 컴포넌트의 속성을 한 번에 변경 (스크립트)
for obj in "Enemy1" "Enemy2" "Enemy3"; do
cd <unity-project-root> && node .unity-websocket/uw comp set "$obj" Rigidbody mass 1.5
cd <unity-project-root> && node .unity-websocket/uw comp set "$obj" AudioSource volume 0.8
done
```
---
## Troubleshooting
### 컴포넌트 타입을 찾을 수 없음
**문제**: `Component type not found`
**해결**:
- 컴포넌트 이름이 정확한지 확인 (대소문자 구분)
- 예: `Rigidbody` (O), `rigidbody` (X), `RigidBody` (X)
- 네임스페이스가 필요한 경우: `UnityEngine.Rigidbody`
### 속성을 변경할 수 없음
**문제**: `Failed to set property`
**해결**:
- 속성 이름이 정확한지 확인
- Inspector에 표시되지 않는 내부 속성(`m_`로 시작)은 변경 불가
- 값의 형식이 맞는지 확인 (예: Vector3는 "x,y,z" 형식)
### 컴포넌트 제거 불가
**문제**: `Cannot remove component`
**해결**:
- Transform은 필수 컴포넌트이므로 제거 불가
- 일부 컴포넌트는 RequireComponent로 인해 제거 불가능할 수 있음
### ObjectReference를 찾을 수 없음
**문제**: `ObjectReference not found: 'GameHUD:UIDocument'`
**해결**:
- **컴포넌트 참조 시 전체 네임스페이스 필수**
-`"GameHUD:UnityEngine.UIElements.UIDocument"`
-`"GameHUD:UIDocument"`
- 일반적인 Unity 네임스페이스:
- `UnityEngine.` - 기본 컴포넌트 (Rigidbody, Collider 등)
- `UnityEngine.UI.` - uGUI 컴포넌트 (Image, Text 등)
- `UnityEngine.UIElements.` - UI Toolkit 컴포넌트 (UIDocument 등)
- GameObject 이름이 정확한지 확인
- 비활성 GameObject는 GameObject.Find로 찾을 수 없음
---
## Related Commands
- [GameObject & Hierarchy Commands](./COMMANDS_GAMEOBJECT_HIERARCHY.md) - GameObject 생성, 계층 구조 관리
- [Transform Commands](./COMMANDS_TRANSFORM.md) - 위치, 회전, 크기 조작
- [Scene Commands](./COMMANDS_SCENE.md) - 씬 관리
- [Asset Commands](./COMMANDS_ASSET.md) - 에셋 및 ScriptableObject 관리

View File

@@ -0,0 +1,99 @@
# Unity Editor Toolkit - Connection & Status Commands
Complete reference for connection and status commands.
**Last Updated**: 2025-01-13
---
## cd <unity-project-root> && node .unity-websocket/uw status
Check Unity WebSocket connection status.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw status
```
**Options:**
```
-p, --port <number> Unity WebSocket port (default: auto-detect from status file)
-v, --verbose Enable verbose logging
-h, --help Display help for command
```
**Example:**
```bash
# Check default connection
cd <unity-project-root> && node .unity-websocket/uw status
# Check specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9500 status
```
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose status
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 status
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw status --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,147 @@
# Unity Editor Toolkit - Console & Logging Commands
Complete reference for Unity console log retrieval and clearing commands.
**Last Updated**: 2025-01-13
---
## cd <unity-project-root> && node .unity-websocket/uw console logs
Get Unity console logs.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw console logs [options]
```
**Options:**
```
-n, --limit <number> Number of recent logs to fetch (default: 50)
-e, --errors-only Show only errors and exceptions
-w, --warnings Include warnings in output
-t, --type <type> Filter by log type: error, warning, log, exception, assert
-f, --filter <text> Filter logs by text (case-insensitive)
-v, --verbose Show full stack traces (default: first 5 lines only)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Get last 50 logs
cd <unity-project-root> && node .unity-websocket/uw console logs
# Get only errors
cd <unity-project-root> && node .unity-websocket/uw console logs --errors-only
# Get last 100 logs with warnings
cd <unity-project-root> && node .unity-websocket/uw console logs --limit 100 --warnings
# Filter logs by text
cd <unity-project-root> && node .unity-websocket/uw console logs --filter "player"
# Get specific log type
cd <unity-project-root> && node .unity-websocket/uw console logs --type error
# Get verbose output with full stack traces
cd <unity-project-root> && node .unity-websocket/uw console logs --verbose --errors-only
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw console logs --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw console clear
Clear Unity console.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw console clear [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Clear console
cd <unity-project-root> && node .unity-websocket/uw console clear
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw console clear --json
```
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose console logs
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 console logs
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw console logs --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,244 @@
# Unity Editor Toolkit - Asset Database & Editor Utilities Commands
Complete reference for Asset Database refresh, recompilation, and asset reimport commands.
**Last Updated**: 2025-01-13
---
## cd <unity-project-root> && node .unity-websocket/uw editor refresh
Refresh Unity AssetDatabase (generates/updates meta files, triggers compilation).
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw editor refresh [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**⚠️ Important Note:**
After running `refresh`, you should check Unity Editor for compilation status. Unity's incremental compilation will automatically compile changed assemblies.
**Examples:**
```bash
# Refresh AssetDatabase
cd <unity-project-root> && node .unity-websocket/uw editor refresh
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw editor refresh --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw editor recompile
Request script recompilation.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw editor recompile [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**⚠️ Important Note:**
Unity's incremental compilation automatically recompiles changed assemblies. This command forces a recompilation check. Check Unity Editor for compilation status after running.
**Examples:**
```bash
# Request recompilation
cd <unity-project-root> && node .unity-websocket/uw editor recompile
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw editor recompile --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw editor reimport
Reimport specific asset (triggers recompilation for that Assembly).
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw editor reimport <path> [options]
```
**Arguments:**
```
<path> Asset path relative to Assets folder (e.g., "XLua" or "Scripts/Player.cs")
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**⚠️ Important Note:**
After running `reimport`, check Unity Editor for reimport and compilation status.
**Examples:**
```bash
# Reimport folder
cd <unity-project-root> && node .unity-websocket/uw editor reimport "XLua"
# Reimport specific asset
cd <unity-project-root> && node .unity-websocket/uw editor reimport "Scripts/Player.cs"
# Reimport .asmdef (recompiles specific Assembly)
cd <unity-project-root> && node .unity-websocket/uw editor reimport "MyPlugin/Editor/MyPlugin.Editor.asmdef"
```
---
## cd <unity-project-root> && node .unity-websocket/uw editor execute
Execute a static method marked with `[ExecutableMethod]` attribute.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw editor execute <commandName> [options]
```
**Arguments:**
```
<commandName> Command name to execute (e.g., reinstall-cli)
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Reinstall CLI
cd <unity-project-root> && node .unity-websocket/uw editor execute reinstall-cli
# List available commands first
cd <unity-project-root> && node .unity-websocket/uw editor list
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw editor execute reinstall-cli --json
```
**Security:**
Only methods explicitly marked with `[ExecutableMethod]` attribute can be executed. This prevents arbitrary code execution.
---
## cd <unity-project-root> && node .unity-websocket/uw editor list
List all executable methods available via `editor execute` command.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw editor list [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# List all executable methods
cd <unity-project-root> && node .unity-websocket/uw editor list
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw editor list --json
```
**Output Format:**
```
✓ Found 1 executable method(s):
reinstall-cli
Reinstall Unity Editor Toolkit CLI
UnityEditorToolkit.Editor.EditorServerWindow.ReinstallCLI
```
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose editor refresh
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 editor recompile
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw editor refresh --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,383 @@
# Unity Editor Toolkit - GameObject & Hierarchy Commands
Complete reference for GameObject manipulation and hierarchy query commands.
**Last Updated**: 2025-01-13
---
## cd <unity-project-root> && node .unity-websocket/uw go find
Find GameObject by name or hierarchical path.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go find <name> [options]
```
**Arguments:**
```
<name> GameObject name or path (e.g., "Player" or "Environment/Trees/Oak")
```
**Options:**
```
-c, --with-components Include component list in output
--with-children Include children hierarchy
--full Include all details (components + children)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Find GameObject by name
cd <unity-project-root> && node .unity-websocket/uw go find "Player"
# Find with full hierarchy path
cd <unity-project-root> && node .unity-websocket/uw go find "Environment/Terrain/Trees"
# Include component information
cd <unity-project-root> && node .unity-websocket/uw go find "Player" --with-components
# Get all details in JSON format
cd <unity-project-root> && node .unity-websocket/uw go find "Enemy" --full --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw go create
Create new GameObject.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go create <name> [options]
```
**Arguments:**
```
<name> Name for the new GameObject
```
**Options:**
```
-p, --parent <parent> Parent GameObject name or path
--primitive <type> Create primitive: cube, sphere, cylinder, capsule, plane, quad
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Create empty GameObject
cd <unity-project-root> && node .unity-websocket/uw go create "NewObject"
# Create with parent
cd <unity-project-root> && node .unity-websocket/uw go create "Child" --parent "Parent"
# Create primitive
cd <unity-project-root> && node .unity-websocket/uw go create "MyCube" --primitive cube
# Create nested object
cd <unity-project-root> && node .unity-websocket/uw go create "Enemy" --parent "Enemies/Group1"
```
---
## cd <unity-project-root> && node .unity-websocket/uw go destroy
Destroy GameObject.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go destroy <name> [options]
```
**Arguments:**
```
<name> GameObject name or path to destroy
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Destroy GameObject
cd <unity-project-root> && node .unity-websocket/uw go destroy "OldObject"
# Destroy nested GameObject
cd <unity-project-root> && node .unity-websocket/uw go destroy "Enemies/Enemy1"
# Get JSON response
cd <unity-project-root> && node .unity-websocket/uw go destroy "Temp" --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw go set-active
Set GameObject active state.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go set-active <name> <active> [options]
```
**Arguments:**
```
<name> GameObject name or path
<active> Active state: true or false
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Activate GameObject
cd <unity-project-root> && node .unity-websocket/uw go set-active "Player" true
# Deactivate GameObject
cd <unity-project-root> && node .unity-websocket/uw go set-active "Enemy" false
# Set nested GameObject state
cd <unity-project-root> && node .unity-websocket/uw go set-active "UI/Menu/Settings" false
```
---
## cd <unity-project-root> && node .unity-websocket/uw go set-parent
Set or remove parent of GameObject.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go set-parent <name> [parent] [options]
```
**Arguments:**
```
<name> GameObject name or path
[parent] Parent GameObject name (omit to remove parent)
```
**Options:**
```
--world-position-stays <bool> Keep world position (default: true)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Set parent (attach "Weapon" to "Player")
cd <unity-project-root> && node .unity-websocket/uw go set-parent "Weapon" "Player"
# Remove parent (detach to root)
cd <unity-project-root> && node .unity-websocket/uw go set-parent "Weapon"
# Set parent without keeping world position
cd <unity-project-root> && node .unity-websocket/uw go set-parent "Child" "Parent" --world-position-stays false
# Reparent nested object
cd <unity-project-root> && node .unity-websocket/uw go set-parent "UI/Menu" "Canvas"
```
---
## cd <unity-project-root> && node .unity-websocket/uw go get-parent
Get parent information of GameObject.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go get-parent <name> [options]
```
**Arguments:**
```
<name> GameObject name or path
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Get parent info
cd <unity-project-root> && node .unity-websocket/uw go get-parent "Weapon"
# Check if object has parent
cd <unity-project-root> && node .unity-websocket/uw go get-parent "Player" --json
# Get parent of nested object
cd <unity-project-root> && node .unity-websocket/uw go get-parent "Enemies/Enemy1"
```
---
## cd <unity-project-root> && node .unity-websocket/uw go get-children
Get children of GameObject.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw go get-children <name> [options]
```
**Arguments:**
```
<name> GameObject name or path
```
**Options:**
```
-r, --recursive Get all descendants (not just direct children)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Get direct children
cd <unity-project-root> && node .unity-websocket/uw go get-children "Player"
# Get all descendants recursively
cd <unity-project-root> && node .unity-websocket/uw go get-children "Player" --recursive
# Get children with JSON output
cd <unity-project-root> && node .unity-websocket/uw go get-children "Canvas" --json
# Count nested objects
cd <unity-project-root> && node .unity-websocket/uw go get-children "Environment" --recursive --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw hierarchy
Query Unity GameObject hierarchy with tree visualization.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw hierarchy [options]
```
**Options:**
```
-r, --root-only Show only root GameObjects (no children)
-i, --include-inactive Include inactive GameObjects in output
-a, --active-only Show only active GameObjects (opposite of -i)
-d, --depth <n> Limit hierarchy depth (e.g., 2 for 2 levels)
-f, --filter <name> Filter GameObjects by name (case-insensitive)
-c, --with-components Include component information for each GameObject
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# View full hierarchy
cd <unity-project-root> && node .unity-websocket/uw hierarchy
# Show only root GameObjects
cd <unity-project-root> && node .unity-websocket/uw hierarchy --root-only
# Limit depth to 2 levels
cd <unity-project-root> && node .unity-websocket/uw hierarchy --depth 2
# Filter by name
cd <unity-project-root> && node .unity-websocket/uw hierarchy --filter "enemy"
# Show only active GameObjects with components
cd <unity-project-root> && node .unity-websocket/uw hierarchy --active-only --with-components
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw hierarchy --json
```
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose hierarchy
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 go find "Player"
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw hierarchy --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,255 @@
# Menu Execution Commands
Unity Editor의 메뉴 항목을 프로그래밍 방식으로 실행하고 조회할 수 있는 명령어입니다.
## Available Commands
| Command | Description |
|---------|-------------|
| `menu run` | Execute a Unity Editor menu item by path |
| `menu list` | List available menu items with optional filtering |
---
## menu run
Unity Editor 메뉴 항목을 경로로 실행합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw menu run <menuPath> [options]
```
### Parameters
- `<menuPath>` - Menu item path (e.g., "Window/General/Console", "Assets/Refresh")
### Options
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout in milliseconds (default: 30000)
### Examples
```bash
# Open Console window
cd <unity-project-root> && node .unity-websocket/uw menu run "Window/General/Console"
# Refresh AssetDatabase
cd <unity-project-root> && node .unity-websocket/uw menu run "Assets/Refresh"
# Open Project Settings
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Project Settings..."
# JSON output
cd <unity-project-root> && node .unity-websocket/uw menu run "Window/General/Inspector" --json
```
### Response
**Success:**
```json
{
"success": true,
"menuPath": "Window/General/Console",
"message": "Menu item 'Window/General/Console' executed successfully"
}
```
**Error:**
```json
{
"error": "Menu item not found: Invalid/Menu/Path"
}
```
### Notes
- Menu path must match exactly (case-sensitive)
- Some menu items may require specific Unity Editor states
- Menu execution is synchronous - waits for completion
- Not all menu items can be executed programmatically
---
## menu list
사용 가능한 Unity Editor 메뉴 항목을 조회합니다.
### Usage
```bash
cd <unity-project-root> && node .unity-websocket/uw menu list [options]
```
### Options
- `--filter <pattern>` - Filter menu items by pattern (supports * wildcard)
- `--json` - Output in JSON format
- `--timeout <ms>` - WebSocket connection timeout in milliseconds (default: 30000)
### Examples
```bash
# List all known menu items
cd <unity-project-root> && node .unity-websocket/uw menu list
# Filter by pattern (wildcard)
cd <unity-project-root> && node .unity-websocket/uw menu list --filter "*Window*"
cd <unity-project-root> && node .unity-websocket/uw menu list --filter "Assets/*"
cd <unity-project-root> && node .unity-websocket/uw menu list --filter "*General*"
# JSON output
cd <unity-project-root> && node .unity-websocket/uw menu list --filter "*Console*" --json
```
### Response
**Success:**
```json
{
"success": true,
"menuItems": [
"Window/General/Console",
"Window/General/Inspector",
"Window/General/Hierarchy",
"Window/General/Project",
"Assets/Refresh",
"Edit/Project Settings..."
],
"count": 6,
"filter": "*General*"
}
```
### Filter Patterns
- `*pattern` - Ends with pattern
- `pattern*` - Starts with pattern
- `*pattern*` - Contains pattern
- `pattern` - Exact match or contains
### Notes
- Returns a predefined list of common Unity menu items
- Wildcard filtering is case-insensitive
- Some menu items may vary by Unity version
- Use exact menu paths with `menu run` command
---
## Common Menu Paths
### Window Menu
```
Window/General/Console
Window/General/Inspector
Window/General/Hierarchy
Window/General/Project
Window/General/Scene
Window/General/Game
Window/Analysis/Profiler
Window/Package Manager
```
### Assets Menu
```
Assets/Refresh
Assets/Reimport
Assets/Reimport All
Assets/Find References In Scene
```
### Edit Menu
```
Edit/Project Settings...
Edit/Preferences...
Edit/Play
Edit/Pause
Edit/Step
```
### GameObject Menu
```
GameObject/Create Empty
GameObject/Create Empty Child
GameObject/3D Object/Cube
GameObject/3D Object/Sphere
GameObject/Light/Directional Light
```
---
## Use Cases
### 1. Open Editor Windows
```bash
# Open Console for debugging
cd <unity-project-root> && node .unity-websocket/uw menu run "Window/General/Console"
# Open Profiler for performance analysis
cd <unity-project-root> && node .unity-websocket/uw menu run "Window/Analysis/Profiler"
```
### 2. Asset Management
```bash
# Refresh AssetDatabase after external changes
cd <unity-project-root> && node .unity-websocket/uw menu run "Assets/Refresh"
# Reimport all assets
cd <unity-project-root> && node .unity-websocket/uw menu run "Assets/Reimport All"
```
### 3. Editor Settings
```bash
# Open Project Settings
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Project Settings..."
# Open Preferences
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Preferences..."
```
### 4. Playmode Control
```bash
# Enter Play mode
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Play"
# Pause
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Pause"
# Step frame
cd <unity-project-root> && node .unity-websocket/uw menu run "Edit/Step"
```
---
## Error Handling
### Menu Not Found
```
Error: Menu item not found: Invalid/Path
```
**Solution**: Use `menu list` to find valid menu paths
### Menu Execution Failed
```
Error: Failed to execute menu: <reason>
```
**Solution**: Check Unity Editor state and menu item availability
### Connection Failed
```
Error: Unity server not running
```
**Solution**: Ensure Unity Editor WebSocket server is running
---
## Best Practices
1. **Verify Menu Paths**: Use `menu list` to verify correct paths
2. **Case Sensitivity**: Menu paths are case-sensitive
3. **Error Handling**: Always check response for success/error
4. **Timeout**: Increase timeout for slow menu operations
5. **JSON Output**: Use `--json` for programmatic parsing

View File

@@ -0,0 +1,527 @@
# Unity Editor Toolkit - Prefab Commands
완전한 Prefab 조작 및 관리 명령어 레퍼런스입니다.
**Last Updated**: 2025-01-26
---
## prefab instantiate
프리팹을 씬에 인스턴스화합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate <path> [options]
```
**Arguments:**
```
<path> 프리팹 에셋 경로 (예: "Assets/Prefabs/Player.prefab")
```
**Options:**
```
--name <name> 인스턴스 이름 지정
--position <x,y,z> 생성 위치 (예: "0,1,0")
--rotation <x,y,z> 회전값 (오일러 각도, 예: "0,90,0")
--parent <gameobject> 부모 GameObject 지정
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 기본 인스턴스화
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/Enemy.prefab"
# 이름과 위치 지정
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/Player.prefab" --name "Player1" --position "0,1,0"
# 부모 지정
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/Item.prefab" --parent "ItemContainer"
# 위치와 회전 지정
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/Car.prefab" --position "10,0,5" --rotation "0,180,0"
```
---
## prefab create
씬의 GameObject에서 프리팹을 생성합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab create <gameobject> <path> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
<path> 저장할 프리팹 경로 (예: "Assets/Prefabs/MyPrefab.prefab")
```
**Options:**
```
--overwrite 기존 프리팹 덮어쓰기
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 새 프리팹 생성
cd <unity-project-root> && node .unity-websocket/uw prefab create "Player" "Assets/Prefabs/Player.prefab"
# 기존 프리팹 덮어쓰기
cd <unity-project-root> && node .unity-websocket/uw prefab create "Enemy" "Assets/Prefabs/Enemy.prefab" --overwrite
# 하위 폴더에 저장
cd <unity-project-root> && node .unity-websocket/uw prefab create "Boss" "Assets/Prefabs/Enemies/Boss.prefab"
```
**Important:**
- 프리팹 생성 후 원본 GameObject는 프리팹 인스턴스로 연결됩니다.
- 경로에 존재하지 않는 폴더는 자동 생성됩니다.
---
## prefab unpack
프리팹 인스턴스를 언팩합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab unpack <gameobject> [options]
```
**Arguments:**
```
<gameobject> 프리팹 인스턴스 이름 또는 경로
```
**Options:**
```
--completely 완전히 언팩 (중첩된 프리팹도 모두 언팩)
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 최상위만 언팩 (기본값)
cd <unity-project-root> && node .unity-websocket/uw prefab unpack "Player"
# 완전히 언팩 (모든 중첩 프리팹 포함)
cd <unity-project-root> && node .unity-websocket/uw prefab unpack "ComplexPrefab" --completely
```
**Unpack Modes:**
| 모드 | 설명 |
|------|------|
| OutermostRoot (기본값) | 최상위 프리팹만 언팩, 중첩 프리팹은 유지 |
| Completely | 모든 중첩 프리팹까지 완전히 언팩 |
---
## prefab apply
프리팹 인스턴스의 오버라이드를 원본 프리팹에 적용합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab apply <gameobject> [options]
```
**Arguments:**
```
<gameobject> 프리팹 인스턴스 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 오버라이드 적용
cd <unity-project-root> && node .unity-websocket/uw prefab apply "Player"
# JSON 응답
cd <unity-project-root> && node .unity-websocket/uw prefab apply "Enemy" --json
```
**Important:**
- 모든 오버라이드가 원본 프리팹에 저장됩니다.
- 다른 씬의 동일 프리팹 인스턴스에도 영향을 줍니다.
- Ctrl+Z (Undo)로 되돌릴 수 있습니다.
---
## prefab revert
프리팹 인스턴스의 오버라이드를 되돌립니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab revert <gameobject> [options]
```
**Arguments:**
```
<gameobject> 프리팹 인스턴스 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 모든 오버라이드 되돌리기
cd <unity-project-root> && node .unity-websocket/uw prefab revert "Player"
```
---
## prefab variant
기존 프리팹에서 Variant를 생성합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab variant <sourcePath> <variantPath> [options]
```
**Arguments:**
```
<sourcePath> 원본 프리팹 경로
<variantPath> Variant 저장 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# Variant 생성
cd <unity-project-root> && node .unity-websocket/uw prefab variant "Assets/Prefabs/Enemy.prefab" "Assets/Prefabs/EnemyBoss.prefab"
# 다른 폴더에 Variant 생성
cd <unity-project-root> && node .unity-websocket/uw prefab variant "Assets/Prefabs/Base/Character.prefab" "Assets/Prefabs/Variants/Warrior.prefab"
```
**Important:**
- Variant는 원본 프리팹의 변경사항을 상속받습니다.
- Variant에서 개별 속성을 오버라이드할 수 있습니다.
---
## prefab overrides
프리팹 인스턴스의 오버라이드 목록을 조회합니다.
**Alias:** `prefab get-overrides`
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab overrides <gameobject> [options]
```
**Arguments:**
```
<gameobject> 프리팹 인스턴스 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Output Icons:**
```
● PropertyOverride (속성 변경)
+ AddedComponent (추가된 컴포넌트)
- RemovedComponent (제거된 컴포넌트)
★ AddedGameObject (추가된 자식 오브젝트)
```
**Examples:**
```bash
# 오버라이드 목록 조회
cd <unity-project-root> && node .unity-websocket/uw prefab overrides "Player"
# JSON으로 조회
cd <unity-project-root> && node .unity-websocket/uw prefab overrides "Enemy" --json
```
---
## prefab source
프리팹 인스턴스의 원본 프리팹 경로를 조회합니다.
**Alias:** `prefab get-source`
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab source <gameobject> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 원본 프리팹 경로 조회
cd <unity-project-root> && node .unity-websocket/uw prefab source "Player"
```
**Output:**
```
✓ Prefab info for 'Player':
Is Prefab Instance: Yes
Prefab Path: Assets/Prefabs/Player.prefab
Prefab Type: Regular
Status: Connected
```
---
## prefab is-instance
GameObject가 프리팹 인스턴스인지 확인합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab is-instance <gameobject> [options]
```
**Arguments:**
```
<gameobject> GameObject 이름 또는 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 프리팹 인스턴스 여부 확인
cd <unity-project-root> && node .unity-websocket/uw prefab is-instance "Player"
```
**Prefab Types:**
| 타입 | 설명 |
|------|------|
| NotAPrefab | 프리팹이 아님 |
| Regular | 일반 프리팹 |
| Model | 모델 프리팹 (FBX 등) |
| Variant | 프리팹 Variant |
| MissingAsset | 원본 에셋 없음 |
---
## prefab open
프리팹을 편집 모드로 엽니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab open <path> [options]
```
**Arguments:**
```
<path> 프리팹 에셋 경로
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 프리팹 편집 모드 열기
cd <unity-project-root> && node .unity-websocket/uw prefab open "Assets/Prefabs/Player.prefab"
```
**Important:**
- 프리팹 편집 모드에서는 씬이 아닌 프리팹 컨텍스트에서 작업합니다.
- 변경사항은 자동 저장되지 않습니다.
- `prefab close`로 편집 모드를 종료합니다.
---
## prefab close
프리팹 편집 모드를 닫고 씬으로 돌아갑니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab close [options]
```
**Options:**
```
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Examples:**
```bash
# 프리팹 편집 모드 닫기
cd <unity-project-root> && node .unity-websocket/uw prefab close
```
---
## prefab list
폴더 내 모든 프리팹을 나열합니다.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefab list [options]
```
**Options:**
```
--path <path> 검색 폴더 경로 (기본값: "Assets")
--json JSON 형식으로 출력
--timeout <ms> WebSocket 연결 타임아웃 (기본값: 30000)
-h, --help 명령어 도움말 표시
```
**Output Icons:**
```
● 일반 프리팹
◇ Variant 프리팹
```
**Examples:**
```bash
# 전체 프리팹 목록
cd <unity-project-root> && node .unity-websocket/uw prefab list
# 특정 폴더만 검색
cd <unity-project-root> && node .unity-websocket/uw prefab list --path "Assets/Prefabs/Characters"
# JSON 형식
cd <unity-project-root> && node .unity-websocket/uw prefab list --json
```
---
## Tips & Best Practices
### 프리팹 워크플로우
```bash
# 1. 씬에서 오브젝트 생성 및 설정
cd <unity-project-root> && node .unity-websocket/uw go create "NewCharacter"
cd <unity-project-root> && node .unity-websocket/uw comp add "NewCharacter" Rigidbody
cd <unity-project-root> && node .unity-websocket/uw comp add "NewCharacter" BoxCollider
# 2. 프리팹으로 저장
cd <unity-project-root> && node .unity-websocket/uw prefab create "NewCharacter" "Assets/Prefabs/NewCharacter.prefab"
# 3. 프리팹 인스턴스화
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/NewCharacter.prefab" --position "10,0,0"
```
### Variant 활용
```bash
# 1. 기본 적 프리팹 생성
cd <unity-project-root> && node .unity-websocket/uw prefab create "BaseEnemy" "Assets/Prefabs/Enemies/BaseEnemy.prefab"
# 2. Variant 생성
cd <unity-project-root> && node .unity-websocket/uw prefab variant "Assets/Prefabs/Enemies/BaseEnemy.prefab" "Assets/Prefabs/Enemies/FastEnemy.prefab"
cd <unity-project-root> && node .unity-websocket/uw prefab variant "Assets/Prefabs/Enemies/BaseEnemy.prefab" "Assets/Prefabs/Enemies/TankEnemy.prefab"
# 3. Variant 인스턴스화 및 수정
cd <unity-project-root> && node .unity-websocket/uw prefab instantiate "Assets/Prefabs/Enemies/FastEnemy.prefab" --name "FastEnemy1"
```
### 오버라이드 관리
```bash
# 1. 오버라이드 확인
cd <unity-project-root> && node .unity-websocket/uw prefab overrides "Player"
# 2. 오버라이드를 원본에 적용
cd <unity-project-root> && node .unity-websocket/uw prefab apply "Player"
# 또는 오버라이드 취소
cd <unity-project-root> && node .unity-websocket/uw prefab revert "Player"
```
---
## Troubleshooting
### 프리팹을 찾을 수 없음
**문제**: `Prefab not found: Assets/Prefabs/MyPrefab.prefab`
**해결**:
- 경로가 정확한지 확인 (대소문자 구분)
- `.prefab` 확장자가 포함되어 있는지 확인
- 에셋이 실제로 존재하는지 확인
### 프리팹 인스턴스가 아님
**문제**: `GameObject is not a prefab instance`
**해결**:
- `prefab is-instance`로 먼저 확인
- 이미 언팩된 오브젝트인 경우 프리팹이 아님
- 씬에서 직접 생성된 오브젝트는 프리팹 인스턴스가 아님
### 프리팹 생성 실패
**문제**: `Prefab already exists: ... Use --overwrite to replace.`
**해결**:
- 같은 경로에 프리팹이 이미 있음
- `--overwrite` 옵션으로 덮어쓰기 가능
---
## Related Commands
- [GameObject & Hierarchy Commands](./COMMANDS_GAMEOBJECT_HIERARCHY.md) - GameObject 생성, 계층 구조 관리
- [Component Commands](./COMMANDS_COMPONENT.md) - 컴포넌트 조작
- [Transform Commands](./COMMANDS_TRANSFORM.md) - 위치, 회전, 크기 조작
- [Asset Commands](./COMMANDS_ASSET.md) - 에셋 및 ScriptableObject 관리

View File

@@ -0,0 +1,250 @@
# Unity Editor Toolkit - EditorPrefs Management Commands
Complete reference for reading, writing, and managing Unity EditorPrefs (persistent editor settings).
**Last Updated**: 2025-01-15
---
## cd <unity-project-root> && node .unity-websocket/uw prefs get
Get EditorPrefs value by key.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefs get <key> [options]
```
**Arguments:**
```
<key> EditorPrefs key name
```
**Options:**
```
-t, --type <type> Value type: string|int|float|bool (default: "string")
-d, --default <value> Default value if key does not exist
--json Output in JSON format
-h, --help Display help for command
```
**Examples:**
```bash
# Get string value
cd <unity-project-root> && node .unity-websocket/uw prefs get "UnityEditorToolkit.DatabaseConfig"
# Get int value with default
cd <unity-project-root> && node .unity-websocket/uw prefs get "MyInt" -t int -d "0"
# Get bool value as JSON
cd <unity-project-root> && node .unity-websocket/uw prefs get "MyBool" -t bool --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw prefs set
Set EditorPrefs value by key.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefs set <key> <value> [options]
```
**Arguments:**
```
<key> EditorPrefs key name
<value> Value to set
```
**Options:**
```
-t, --type <type> Value type: string|int|float|bool (default: "string")
--json Output in JSON format
-h, --help Display help for command
```
**Examples:**
```bash
# Set string value
cd <unity-project-root> && node .unity-websocket/uw prefs set "MyKey" "MyValue"
# Set int value
cd <unity-project-root> && node .unity-websocket/uw prefs set "MyInt" "42" -t int
# Set bool value
cd <unity-project-root> && node .unity-websocket/uw prefs set "MyBool" "true" -t bool
# Set float value as JSON
cd <unity-project-root> && node .unity-websocket/uw prefs set "MyFloat" "3.14" -t float --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw prefs delete
Delete EditorPrefs key.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefs delete <key> [options]
```
**Arguments:**
```
<key> EditorPrefs key name to delete
```
**Options:**
```
--json Output in JSON format
-h, --help Display help for command
```
**⚠️ Warning:**
Deletion is irreversible. Make sure you have the correct key name.
**Examples:**
```bash
# Delete key
cd <unity-project-root> && node .unity-websocket/uw prefs delete "MyKey"
# Delete with JSON output
cd <unity-project-root> && node .unity-websocket/uw prefs delete "OldConfig" --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw prefs clear
Delete all EditorPrefs (WARNING: irreversible).
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefs clear [options]
```
**Options:**
```
--force Skip confirmation prompt (REQUIRED)
--json Output in JSON format
-h, --help Display help for command
```
**⚠️ DANGER:**
This command deletes **ALL** EditorPrefs data for the entire Unity Editor, not just the current project. Use with extreme caution. **Always backup your settings first!**
**Examples:**
```bash
# Attempt to clear (will show warning without --force)
cd <unity-project-root> && node .unity-websocket/uw prefs clear
# Force clear all EditorPrefs
cd <unity-project-root> && node .unity-websocket/uw prefs clear --force
# Clear with JSON output
cd <unity-project-root> && node .unity-websocket/uw prefs clear --force --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw prefs has
Check if EditorPrefs key exists. If key exists, also returns its type and value.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw prefs has <key> [options]
```
**Arguments:**
```
<key> EditorPrefs key name to check
```
**Options:**
```
--json Output in JSON format
-h, --help Display help for command
```
**Output:**
```
Key: <key-name>
Exists: Yes/No
Type: string|int|float|bool (only if exists)
Value: <value> (only if exists)
```
**Examples:**
```bash
# Check if key exists (shows value if exists)
cd <unity-project-root> && node .unity-websocket/uw prefs has "UnityEditorToolkit.Database.EnableWAL"
# Output:
# Key: UnityEditorToolkit.Database.EnableWAL
# Exists: Yes
# Type: bool
# Value: true
# Check non-existent key
cd <unity-project-root> && node .unity-websocket/uw prefs has "NonExistentKey"
# Output:
# Key: NonExistentKey
# Exists: No
# Check with JSON output
cd <unity-project-root> && node .unity-websocket/uw prefs has "MyKey" --json
```
---
## Common Use Cases
### Debug DatabaseConfig
```bash
# Check if config exists
cd <unity-project-root> && node .unity-websocket/uw prefs has "UnityEditorToolkit.DatabaseConfig"
# Get current config (JSON format)
cd <unity-project-root> && node .unity-websocket/uw prefs get "UnityEditorToolkit.DatabaseConfig"
# Reset config (delete)
cd <unity-project-root> && node .unity-websocket/uw prefs delete "UnityEditorToolkit.DatabaseConfig"
```
### Manual Configuration
```bash
# Set custom database path
cd <unity-project-root> && node .unity-websocket/uw prefs set "CustomDatabasePath" "D:/MyData/db.sqlite"
# Enable feature flag
cd <unity-project-root> && node .unity-websocket/uw prefs set "FeatureEnabled" "true" -t bool
# Set numeric setting
cd <unity-project-root> && node .unity-websocket/uw prefs set "MaxConnections" "10" -t int
```
---
## EditorPrefs Storage Location
EditorPrefs are stored per-Unity-Editor (not per-project):
- **Windows**: `HKEY_CURRENT_USER\Software\Unity\UnityEditor\CompanyName\ProductName`
- **macOS**: `~/Library/Preferences/com.CompanyName.ProductName.plist`
- **Linux**: `~/.config/unity3d/CompanyName/ProductName/prefs`
**Note**: CompanyName and ProductName are from your Unity Project Settings.
---
## See Also
- [Connection & Status Commands](./COMMANDS_CONNECTION_STATUS.md)
- [GameObject & Hierarchy Commands](./COMMANDS_GAMEOBJECT_HIERARCHY.md)
- [Transform Commands](./COMMANDS_TRANSFORM.md)
- [Scene Management Commands](./COMMANDS_SCENE.md)
- [Asset Database & Editor Commands](./COMMANDS_EDITOR.md)
- [Console & Logging Commands](./COMMANDS_CONSOLE.md)

View File

@@ -0,0 +1,306 @@
# Unity Editor Toolkit - Scene Management Commands
Complete reference for scene management commands.
**Last Updated**: 2025-01-25
**Commands**: 7 commands
---
## cd <unity-project-root> && node .unity-websocket/uw scene current
Get current active scene information.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene current [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Get current scene info
cd <unity-project-root> && node .unity-websocket/uw scene current
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw scene current --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw scene list
List all loaded scenes.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene list [options]
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# List all scenes
cd <unity-project-root> && node .unity-websocket/uw scene list
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw scene list --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw scene load
Load scene by name or path.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene load <name> [options]
```
**Arguments:**
```
<name> Scene name or path (without .unity extension)
```
**Options:**
```
-a, --additive Load scene additively (don't unload current scenes)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Load scene (replace current)
cd <unity-project-root> && node .unity-websocket/uw scene load "MainMenu"
# Load scene additively
cd <unity-project-root> && node .unity-websocket/uw scene load "UIOverlay" --additive
# Load scene by path
cd <unity-project-root> && node .unity-websocket/uw scene load "Assets/Scenes/Level1"
```
---
## cd <unity-project-root> && node .unity-websocket/uw scene new
Create a new scene.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene new [options]
```
**Options:**
```
-e, --empty Create empty scene (no default camera/light)
-a, --additive Add new scene without replacing current scenes
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Create new scene with default objects (Main Camera, Directional Light)
cd <unity-project-root> && node .unity-websocket/uw scene new
# Create empty scene
cd <unity-project-root> && node .unity-websocket/uw scene new --empty
# Create new scene additively (keep current scenes)
cd <unity-project-root> && node .unity-websocket/uw scene new --additive
# Create empty scene additively
cd <unity-project-root> && node .unity-websocket/uw scene new -e -a
```
---
## cd <unity-project-root> && node .unity-websocket/uw scene save
Save scene to disk.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene save [path] [options]
```
**Arguments:**
```
[path] Optional path for Save As (e.g., "Assets/Scenes/NewScene.unity")
```
**Options:**
```
-s, --scene <name> Specific scene name to save (default: active scene)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Save active scene
cd <unity-project-root> && node .unity-websocket/uw scene save
# Save As - save to new location
cd <unity-project-root> && node .unity-websocket/uw scene save "Assets/Scenes/Level2.unity"
# Save specific scene (multi-scene editing)
cd <unity-project-root> && node .unity-websocket/uw scene save --scene "UIScene"
```
---
## cd <unity-project-root> && node .unity-websocket/uw scene unload
Unload a scene from the editor.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene unload <name> [options]
```
**Arguments:**
```
<name> Scene name or path to unload
```
**Options:**
```
-r, --remove Remove scene completely (default: just unload/close)
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Unload scene by name
cd <unity-project-root> && node .unity-websocket/uw scene unload "UIOverlay"
# Unload scene by path
cd <unity-project-root> && node .unity-websocket/uw scene unload "Assets/Scenes/Level1.unity"
# Remove scene completely
cd <unity-project-root> && node .unity-websocket/uw scene unload "TempScene" --remove
```
**Note:** Cannot unload the last remaining scene. At least one scene must always be loaded.
---
## cd <unity-project-root> && node .unity-websocket/uw scene set-active
Set a scene as the active scene (for multi-scene editing).
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw scene set-active <name> [options]
```
**Arguments:**
```
<name> Scene name or path to set as active
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Set active scene by name
cd <unity-project-root> && node .unity-websocket/uw scene set-active "MainScene"
# Set active scene by path
cd <unity-project-root> && node .unity-websocket/uw scene set-active "Assets/Scenes/Level1.unity"
```
**Note:** The target scene must be loaded before it can be set as active.
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose scene current
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 scene load "Level1"
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw scene load "Level1" --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,215 @@
# Unity Editor Toolkit - Transform Commands
Complete reference for Transform manipulation commands.
**Last Updated**: 2025-01-13
---
## cd <unity-project-root> && node .unity-websocket/uw tf get
Get Transform information (position, rotation, scale).
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw tf get <name> [options]
```
**Arguments:**
```
<name> GameObject name or path
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Get Transform info
cd <unity-project-root> && node .unity-websocket/uw tf get "Player"
# Get nested GameObject Transform
cd <unity-project-root> && node .unity-websocket/uw tf get "Environment/Trees/Oak"
# Get JSON output
cd <unity-project-root> && node .unity-websocket/uw tf get "Enemy" --json
```
---
## cd <unity-project-root> && node .unity-websocket/uw tf set-position
Set Transform position.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw tf set-position <name> <position> [options]
```
**Arguments:**
```
<name> GameObject name or path
<position> Position as "x,y,z" (e.g., "0,5,10")
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Set position
cd <unity-project-root> && node .unity-websocket/uw tf set-position "Player" "0,5,10"
# Set position with negative values
cd <unity-project-root> && node .unity-websocket/uw tf set-position "Enemy" "-5.5,0,3.2"
# Set nested GameObject position
cd <unity-project-root> && node .unity-websocket/uw tf set-position "UI/Menu/Button" "100,50,0"
```
---
## cd <unity-project-root> && node .unity-websocket/uw tf set-rotation
Set Transform rotation using Euler angles.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw tf set-rotation <name> <rotation> [options]
```
**Arguments:**
```
<name> GameObject name or path
<rotation> Euler angles as "x,y,z" in degrees (e.g., "0,90,0")
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Rotate 90 degrees on Y axis
cd <unity-project-root> && node .unity-websocket/uw tf set-rotation "Player" "0,90,0"
# Set rotation with all axes
cd <unity-project-root> && node .unity-websocket/uw tf set-rotation "Camera" "30,45,0"
# Reset rotation
cd <unity-project-root> && node .unity-websocket/uw tf set-rotation "Enemy" "0,0,0"
```
---
## cd <unity-project-root> && node .unity-websocket/uw tf set-scale
Set Transform scale.
**Usage:**
```bash
cd <unity-project-root> && node .unity-websocket/uw tf set-scale <name> <scale> [options]
```
**Arguments:**
```
<name> GameObject name or path
<scale> Scale as "x,y,z" (e.g., "2,2,2")
```
**Options:**
```
--json Output in JSON format
--timeout <ms> Connection timeout in milliseconds (default: 30000)
-h, --help Display help for command
```
**Examples:**
```bash
# Double size
cd <unity-project-root> && node .unity-websocket/uw tf set-scale "Cube" "2,2,2"
# Scale only on Y axis
cd <unity-project-root> && node .unity-websocket/uw tf set-scale "Platform" "1,0.5,1"
# Non-uniform scaling
cd <unity-project-root> && node .unity-websocket/uw tf set-scale "Wall" "5,3,0.2"
```
---
## Global Options
All commands support these global options:
```
-V, --version Output the version number
-v, --verbose Enable verbose logging
-p, --port <number> Unity WebSocket port (overrides auto-detection)
-h, --help Display help for command
```
**Examples:**
```bash
# Check CLI version
cd <unity-project-root> && node .unity-websocket/uw --version
# Enable verbose logging
cd <unity-project-root> && node .unity-websocket/uw --verbose tf get "Player"
# Use specific port
cd <unity-project-root> && node .unity-websocket/uw --port 9501 tf set-position "Enemy" "0,0,0"
```
---
## Notes
### Port Auto-Detection
Unity Editor Toolkit CLI automatically detects the Unity WebSocket server port by reading `.unity-websocket/server-status.json` in the Unity project directory. You only need to specify `--port` if:
- Running multiple Unity Editor instances
- Server is using non-default port range
### JSON Output
All commands support `--json` flag for machine-readable output. Useful for:
- CI/CD pipelines
- Automation scripts
- Integration with other tools
### Timeout Configuration
Default timeout is 30 seconds (30000ms). Increase for operations that may take longer:
```bash
# Longer timeout for complex operations
cd <unity-project-root> && node .unity-websocket/uw tf get "Player" --timeout 60000
```
### Error Handling
Commands return appropriate exit codes:
- `0`: Success
- `1`: Error (connection failed, command failed, invalid parameters, etc.)
Check error messages for details on failures.
---
**See Also:**
- [QUICKSTART.md](../../QUICKSTART.md) - Quick setup and first commands
- [COMMANDS.md](./COMMANDS.md) - Complete command roadmap
- [API_COMPATIBILITY.md](../../API_COMPATIBILITY.md) - Unity version compatibility
- [TEST_GUIDE.md](../../TEST_GUIDE.md) - Unity C# server testing guide

View File

@@ -0,0 +1,234 @@
# Wait Commands Reference
Wait for various Unity conditions before proceeding.
## Command Format
```bash
cd <unity-project-root>
node .unity-websocket/uw.js wait <subcommand> [options]
```
## Subcommands
### wait compile
Wait for Unity compilation to complete.
**Usage:**
```bash
node .unity-websocket/uw.js wait compile [options]
```
**Options:**
- `--json` - Output in JSON format
- `--timeout <ms>` - Timeout in milliseconds (default: 300000 = 5 minutes)
**Examples:**
```bash
# Wait for compilation to complete
cd <unity-project-root> && node .unity-websocket/uw.js wait compile
# Custom timeout (30 seconds)
cd <unity-project-root> && node .unity-websocket/uw.js wait compile --timeout 30000
```
**Use Cases:**
- Wait after making code changes
- Ensure compilation is done before running tests
- Sequential automation workflows
---
### wait playmode
Wait for specific play mode state.
**Usage:**
```bash
node .unity-websocket/uw.js wait playmode <state> [options]
```
**Arguments:**
- `<state>` - Target state: `enter`, `exit`, or `pause`
**Options:**
- `--json` - Output in JSON format
- `--timeout <ms>` - Timeout in milliseconds (default: 300000 = 5 minutes)
**Examples:**
```bash
# Wait for play mode to start
cd <unity-project-root> && node .unity-websocket/uw.js wait playmode enter
# Wait for play mode to exit
cd <unity-project-root> && node .unity-websocket/uw.js wait playmode exit
# Wait for pause
cd <unity-project-root> && node .unity-websocket/uw.js wait playmode pause
```
**Use Cases:**
- Synchronize with play mode testing
- Wait for game to start before sending commands
- Automation workflows that require play mode
---
### wait sleep
Sleep for a specified duration.
**Usage:**
```bash
node .unity-websocket/uw.js wait sleep <seconds> [options]
```
**Arguments:**
- `<seconds>` - Duration in seconds (can be decimal, e.g., 0.5 for half a second)
**Options:**
- `--json` - Output in JSON format
- `--timeout <ms>` - Timeout in milliseconds (must be greater than sleep duration)
**Examples:**
```bash
# Sleep for 2 seconds
cd <unity-project-root> && node .unity-websocket/uw.js wait sleep 2
# Sleep for half a second
cd <unity-project-root> && node .unity-websocket/uw.js wait sleep 0.5
# Sleep with custom timeout
cd <unity-project-root> && node .unity-websocket/uw.js wait sleep 5 --timeout 10000
```
**Use Cases:**
- Add delays between commands
- Wait for UI animations
- Rate limiting in automation
---
### wait scene
Wait for scene to finish loading (play mode only).
**Usage:**
```bash
node .unity-websocket/uw.js wait scene [options]
```
**Options:**
- `--json` - Output in JSON format
- `--timeout <ms>` - Timeout in milliseconds (default: 300000 = 5 minutes)
**Examples:**
```bash
# Wait for scene to load
cd <unity-project-root> && node .unity-websocket/uw.js wait scene
```
**Requirements:**
- Unity must be in play mode
- Scene must be actively loading or just loaded
**Use Cases:**
- Wait after loading a new scene
- Ensure scene is ready before running tests
- Sequential scene loading workflows
---
## Important Notes
### Delayed Response Model
Wait commands use a **delayed response** model:
1. Command is sent to Unity
2. Unity registers the wait condition
3. Connection remains open
4. Unity monitors the condition every frame
5. Response is sent when condition is met or timeout occurs
### Timeout Behavior
- Default timeout: **300 seconds (5 minutes)**
- If condition is met before timeout: Success response
- If timeout occurs: Error response with timeout message
- Recommendation: Set timeout longer than expected wait time
### Domain Reload Handling
If Unity compiles scripts (domain reload) while waiting:
- All pending wait requests are **automatically cancelled**
- Clients receive error: "Script compilation started, request cancelled"
- This prevents orphaned wait requests
### Server Stop Handling
If Unity WebSocket server stops while waiting:
- All pending wait requests are **automatically cancelled**
- Clients receive error: "Server stopping"
---
## JSON Output Format
When using `--json` flag:
**Success:**
```json
{
"success": true,
"type": "sleep",
"seconds": 2,
"message": "Slept for 2 seconds"
}
```
**Error:**
```json
{
"jsonrpc": "2.0",
"id": "...",
"error": {
"code": -32000,
"message": "Wait condition timed out after 300 seconds"
}
}
```
---
## Common Workflows
### Wait for Compilation then Execute
```bash
# Wait for compilation, then refresh AssetDatabase
cd <unity-project-root>
node .unity-websocket/uw.js wait compile
node .unity-websocket/uw.js editor refresh
```
### Sequential Scene Loading
```bash
# Load scene, wait for it, then do something
cd <unity-project-root>
node .unity-websocket/uw.js scene load MainMenu
node .unity-websocket/uw.js wait scene
node .unity-websocket/uw.js gameobject find "StartButton"
```
### Rate-Limited Automation
```bash
# Do something, wait, repeat
cd <unity-project-root>
for i in {1..5}; do
node .unity-websocket/uw.js console logs --limit 10
node .unity-websocket/uw.js wait sleep 1
done
```

View File

@@ -0,0 +1,693 @@
# Unity Editor Toolkit - Database Guide
Complete guide for Unity Editor Toolkit's SQLite database integration and real-time GameObject synchronization.
## Overview
Unity Editor Toolkit provides a complete SQLite database integration for real-time GameObject synchronization, analytics, and version control capabilities.
### Key Features
- **GUID-based Persistence**: GameObjects are identified by persistent GUIDs across Unity sessions
- **Real-time Synchronization**: Auto-sync all loaded scenes every 1 second
- **Multi-scene Support**: Synchronize all loaded scenes simultaneously
- **Command Pattern**: Undo/Redo support for database operations
- **Auto Migration**: Automatic schema migration system
- **Batch Operations**: Efficient bulk operations (500 objects/batch)
- **Security**: SQL injection prevention with parameterized queries and transaction safety
## Database Setup
### 1. Unity Editor Setup
1. Open **Unity Editor Toolkit Server** window
```
Tools > Unity Editor Toolkit > Server Window
```
2. Switch to **"Database"** tab
3. Click **"Connect"** to initialize SQLite database
- Database file: `{ProjectRoot}/.unity-websocket/unity-editor.db`
- Auto-creates schema with migrations
4. Enable Real-time Sync (Optional)
- Click **"Start Sync"** for auto-sync (1s interval)
- All loaded scenes are synchronized automatically
- GameObjects automatically tagged with GUID components
### 2. Database File Location
```
{ProjectRoot}/
└── .unity-websocket/
├── unity-editor.db # SQLite database
├── server-status.json # WebSocket status
└── uw.js # CLI wrapper
```
## CLI Commands
All database commands run from the Unity project root:
```bash
cd <unity-project-root> && node .unity-websocket/uw <command> [options]
```
### Database Management (`db`)
#### Connect to Database
```bash
# Connect and initialize database
cd <unity-project-root> && node .unity-websocket/uw db connect
# Connect with WAL mode disabled (default: enabled)
cd <unity-project-root> && node .unity-websocket/uw db connect --no-wal
```
**WAL Mode** (Write-Ahead Logging):
- Default: Enabled for better performance
- Multiple readers, single writer
- Disable with `--no-wal` for compatibility
#### Check Database Status
```bash
# Get connection and health status
cd <unity-project-root> && node .unity-websocket/uw db status
# Output in JSON format
cd <unity-project-root> && node .unity-websocket/uw db status --json
```
Output includes:
- Connection status
- Database file path and existence
- Initialization state
- Auto-sync status
#### Disconnect from Database
```bash
# Safely disconnect and cleanup
cd <unity-project-root> && node .unity-websocket/uw db disconnect
```
#### Reset Database
```bash
# Delete and recreate database with fresh migrations
cd <unity-project-root> && node .unity-websocket/uw db reset
# Confirm reset
cd <unity-project-root> && node .unity-websocket/uw db reset --yes
```
**Warning**: Deletes all data!
#### Run Migrations
```bash
# Apply pending migrations
cd <unity-project-root> && node .unity-websocket/uw db migrate
# Force re-run all migrations
cd <unity-project-root> && node .unity-websocket/uw db clear-migrations
cd <unity-project-root> && node .unity-websocket/uw db migrate
```
### Scene Synchronization (`sync`)
#### Sync Entire Scene
```bash
# Sync current active scene to database
cd <unity-project-root> && node .unity-websocket/uw sync scene
# Keep existing data (no clear)
cd <unity-project-root> && node .unity-websocket/uw sync scene --no-clear
# Skip components (GameObject only)
cd <unity-project-root> && node .unity-websocket/uw sync scene --no-components
# Skip hierarchy closure table
cd <unity-project-root> && node .unity-websocket/uw sync scene --no-closure
# JSON output
cd <unity-project-root> && node .unity-websocket/uw sync scene --json
```
**Closure Table**: Stores parent-child relationships for efficient hierarchy queries.
#### Sync Specific GameObject
```bash
# Sync single GameObject
cd <unity-project-root> && node .unity-websocket/uw sync object "Player"
# Sync with full hierarchy path
cd <unity-project-root> && node .unity-websocket/uw sync object "Environment/Trees/Oak"
# Include children
cd <unity-project-root> && node .unity-websocket/uw sync object "Player" --children
# Skip components
cd <unity-project-root> && node .unity-websocket/uw sync object "Player" --no-components
```
#### Check Sync Status
```bash
# Get sync status for current scene
cd <unity-project-root> && node .unity-websocket/uw sync status
# JSON output
cd <unity-project-root> && node .unity-websocket/uw sync status --json
```
Output includes:
- Unity object count
- Database object count
- Component count
- Closure record count
- In-sync status
#### Clear Sync Data
```bash
# Clear all sync data for current scene
cd <unity-project-root> && node .unity-websocket/uw sync clear
# Confirm clear
cd <unity-project-root> && node .unity-websocket/uw sync clear --yes
```
#### Auto-Sync Control
```bash
# Start auto-sync (1s interval)
cd <unity-project-root> && node .unity-websocket/uw sync start
# Stop auto-sync
cd <unity-project-root> && node .unity-websocket/uw sync stop
# Get auto-sync status
cd <unity-project-root> && node .unity-websocket/uw sync auto-status
```
Auto-sync status includes:
- Running state
- Last sync time
- Success/fail counts
- Sync interval (ms)
- Batch size
### Analytics (`analytics`)
#### Scene Analytics
```bash
# Get scene statistics
cd <unity-project-root> && node .unity-websocket/uw analytics scene
# JSON output
cd <unity-project-root> && node .unity-websocket/uw analytics scene --json
```
Output includes:
- Total GameObjects
- Total Components
- Active vs inactive objects
- Object hierarchy depth
- Component type distribution
#### GameObject Analytics
```bash
# Get GameObject statistics
cd <unity-project-root> && node .unity-websocket/uw analytics objects
# Filter by active state
cd <unity-project-root> && node .unity-websocket/uw analytics objects --active-only
```
#### Component Analytics
```bash
# Get component type distribution
cd <unity-project-root> && node .unity-websocket/uw analytics components
# Top N most used components
cd <unity-project-root> && node .unity-websocket/uw analytics components --top 10
```
#### Tag Analytics
```bash
# Get tag usage statistics
cd <unity-project-root> && node .unity-websocket/uw analytics tags
```
#### Layer Analytics
```bash
# Get layer usage statistics
cd <unity-project-root> && node .unity-websocket/uw analytics layers
```
### Snapshots (`snapshot`)
Snapshots capture the complete state of GameObjects and Components at a specific point in time.
#### Create Snapshot
```bash
# Create snapshot of current scene
cd <unity-project-root> && node .unity-websocket/uw snapshot create "Before Refactor"
# Create snapshot with description
cd <unity-project-root> && node .unity-websocket/uw snapshot create "v1.0 Release" \
--description "Scene state before major refactor"
```
#### List Snapshots
```bash
# List all snapshots
cd <unity-project-root> && node .unity-websocket/uw snapshot list
# JSON output
cd <unity-project-root> && node .unity-websocket/uw snapshot list --json
```
#### Get Snapshot Details
```bash
# Get snapshot by ID
cd <unity-project-root> && node .unity-websocket/uw snapshot get 1
# JSON output
cd <unity-project-root> && node .unity-websocket/uw snapshot get 1 --json
```
#### Compare Snapshots
```bash
# Compare two snapshots
cd <unity-project-root> && node .unity-websocket/uw snapshot compare 1 2
# Show differences only
cd <unity-project-root> && node .unity-websocket/uw snapshot compare 1 2 --diff-only
```
Output includes:
- Added objects
- Removed objects
- Modified objects
- Component changes
#### Restore Snapshot
```bash
# Restore scene from snapshot
cd <unity-project-root> && node .unity-websocket/uw snapshot restore 1
# Confirm restore
cd <unity-project-root> && node .unity-websocket/uw snapshot restore 1 --yes
```
**Warning**: Overwrites current scene state!
#### Delete Snapshot
```bash
# Delete snapshot by ID
cd <unity-project-root> && node .unity-websocket/uw snapshot delete 1
# Confirm delete
cd <unity-project-root> && node .unity-websocket/uw snapshot delete 1 --yes
```
### Transform History (`transform-history`)
Track position, rotation, and scale changes over time with Undo/Redo support.
#### Start Recording
```bash
# Start recording transform changes
cd <unity-project-root> && node .unity-websocket/uw transform-history start
# Record specific GameObject
cd <unity-project-root> && node .unity-websocket/uw transform-history start "Player"
```
#### Stop Recording
```bash
# Stop recording
cd <unity-project-root> && node .unity-websocket/uw transform-history stop
```
#### Get History
```bash
# Get transform history for GameObject
cd <unity-project-root> && node .unity-websocket/uw transform-history get "Player"
# Limit results
cd <unity-project-root> && node .unity-websocket/uw transform-history get "Player" --limit 10
# JSON output
cd <unity-project-root> && node .unity-websocket/uw transform-history get "Player" --json
```
#### Compare Transforms
```bash
# Compare transform between two timestamps
cd <unity-project-root> && node .unity-websocket/uw transform-history compare "Player" \
--from "2025-11-19T10:00:00" \
--to "2025-11-19T11:00:00"
```
#### Undo/Redo
```bash
# Undo last transform change
cd <unity-project-root> && node .unity-websocket/uw transform-history undo "Player"
# Redo last undone change
cd <unity-project-root> && node .unity-websocket/uw transform-history redo "Player"
# Undo N steps
cd <unity-project-root> && node .unity-websocket/uw transform-history undo "Player" --steps 3
```
#### Clear History
```bash
# Clear history for specific GameObject
cd <unity-project-root> && node .unity-websocket/uw transform-history clear "Player"
# Clear all history
cd <unity-project-root> && node .unity-websocket/uw transform-history clear-all --yes
```
## Database Schema
### Core Tables
#### `scenes`
Stores scene information.
```sql
CREATE TABLE scenes (
scene_id INTEGER PRIMARY KEY AUTOINCREMENT,
scene_path TEXT NOT NULL UNIQUE,
scene_name TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
```
#### `gameobjects`
Stores GameObject data with GUID-based identification.
```sql
CREATE TABLE gameobjects (
object_id INTEGER PRIMARY KEY AUTOINCREMENT,
guid TEXT UNIQUE, -- Persistent GUID
instance_id INTEGER NOT NULL,
scene_id INTEGER NOT NULL,
object_name TEXT NOT NULL,
parent_id INTEGER,
tag TEXT,
layer INTEGER,
is_active BOOLEAN DEFAULT 1,
is_static BOOLEAN DEFAULT 0,
is_deleted BOOLEAN DEFAULT 0, -- Soft delete
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (scene_id) REFERENCES scenes(scene_id)
);
```
#### `gameobject_closure`
Stores hierarchy relationships for efficient queries.
```sql
CREATE TABLE gameobject_closure (
ancestor_id INTEGER NOT NULL,
descendant_id INTEGER NOT NULL,
depth INTEGER NOT NULL,
PRIMARY KEY (ancestor_id, descendant_id),
FOREIGN KEY (ancestor_id) REFERENCES gameobjects(object_id),
FOREIGN KEY (descendant_id) REFERENCES gameobjects(object_id)
);
```
#### `migrations`
Tracks applied schema migrations.
```sql
CREATE TABLE migrations (
migration_id INTEGER PRIMARY KEY AUTOINCREMENT,
migration_name TEXT NOT NULL UNIQUE,
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
```
### Migration History
- **Migration_001**: Initial schema (scenes, gameobjects, migrations)
- **Migration_002**: Add GUID column to gameobjects table
## Security
### SQL Injection Prevention
All database operations use **parameterized queries**:
```csharp
// ✓ Safe (parameterized)
connection.Execute("DELETE FROM gameobjects WHERE guid = ?", guid);
// ✗ Unsafe (string concatenation)
connection.Execute($"DELETE FROM gameobjects WHERE guid = '{guid}'");
```
**Batch Operations**:
- ≤100 items: Individual parameterized DELETE statements
- >100 items: Temporary table pattern with transaction
### Transaction Safety
**Nested Transaction Prevention**:
```csharp
ExecuteInTransaction(connection, () => {
// Safe transaction execution
// Detects and prevents nested transactions
// Graceful fallback if transaction already started
});
```
### Memory Safety
**Domain Reload Safety**:
```csharp
if (!isDisposed)
{
await UniTask.SwitchToMainThread();
}
```
Prevents crashes during Unity Domain Reload.
## Best Practices
### 1. Connection Management
```bash
# Always check status before operations
cd <unity-project-root> && node .unity-websocket/uw db status
# Connect once at session start
cd <unity-project-root> && node .unity-websocket/uw db connect
# Disconnect at session end
cd <unity-project-root> && node .unity-websocket/uw db disconnect
```
### 2. Auto-Sync Usage
**When to use**:
- Active development with frequent GameObject changes
- Real-time analytics and monitoring
- Multi-scene editing
**When to disable**:
- Performance-critical operations
- Large scene modifications (use manual sync)
- Prefab editing
### 3. Snapshot Workflow
```bash
# Before major changes
cd <unity-project-root> && node .unity-websocket/uw snapshot create "Before Refactor"
# Make changes...
# If something goes wrong
cd <unity-project-root> && node .unity-websocket/uw snapshot restore 1 --yes
# After successful changes
cd <unity-project-root> && node .unity-websocket/uw snapshot create "After Refactor"
```
### 4. Performance Optimization
**Batch Operations**:
- Use `sync scene` for full scene sync (more efficient than individual objects)
- Disable components with `--no-components` if not needed
- Skip closure table with `--no-closure` for flat hierarchies
**Auto-Sync Interval**:
- Default: 1000ms (1 second)
- Adjust in Unity Editor window if needed
- Disable during intensive operations
### 5. Analytics Workflow
```bash
# Get scene overview
cd <unity-project-root> && node .unity-websocket/uw analytics scene
# Identify performance issues
cd <unity-project-root> && node .unity-websocket/uw analytics components --top 10
# Check tag/layer usage
cd <unity-project-root> && node .unity-websocket/uw analytics tags
cd <unity-project-root> && node .unity-websocket/uw analytics layers
```
## Troubleshooting
### Database Connection Failed
```bash
# Check Unity Editor is running
cd <unity-project-root> && node .unity-websocket/uw status
# Check database status
cd <unity-project-root> && node .unity-websocket/uw db status
# Reconnect
cd <unity-project-root> && node .unity-websocket/uw db connect
```
### Sync Issues
```bash
# Check sync status
cd <unity-project-root> && node .unity-websocket/uw sync status
# Clear and resync
cd <unity-project-root> && node .unity-websocket/uw sync clear --yes
cd <unity-project-root> && node .unity-websocket/uw sync scene
```
### Migration Errors
```bash
# Reset and reapply migrations
cd <unity-project-root> && node .unity-websocket/uw db reset --yes
cd <unity-project-root> && node .unity-websocket/uw db migrate
```
### Performance Issues
```bash
# Stop auto-sync
cd <unity-project-root> && node .unity-websocket/uw sync stop
# Use manual sync with optimizations
cd <unity-project-root> && node .unity-websocket/uw sync scene --no-closure
```
## Examples
### Complete Workflow Example
```bash
# 1. Initialize database
cd /path/to/unity/project
node .unity-websocket/uw db connect
# 2. Sync current scene
node .unity-websocket/uw sync scene
# 3. Create snapshot
node .unity-websocket/uw snapshot create "Initial State"
# 4. Get analytics
node .unity-websocket/uw analytics scene --json
# 5. Start auto-sync
node .unity-websocket/uw sync start
# 6. Make changes in Unity Editor...
# 7. Check sync status
node .unity-websocket/uw sync status
# 8. Create another snapshot
node .unity-websocket/uw snapshot create "After Changes"
# 9. Compare snapshots
node .unity-websocket/uw snapshot compare 1 2
# 10. Cleanup
node .unity-websocket/uw sync stop
node .unity-websocket/uw db disconnect
```
### CI/CD Integration
```bash
#!/bin/bash
# Build validation script
cd /path/to/unity/project
# Initialize
node .unity-websocket/uw db connect
# Sync and analyze
node .unity-websocket/uw sync scene
node .unity-websocket/uw analytics scene --json > scene-stats.json
# Validate object count
OBJECT_COUNT=$(cat scene-stats.json | jq '.totalObjects')
if [ "$OBJECT_COUNT" -gt 10000 ]; then
echo "❌ Scene too complex: $OBJECT_COUNT objects"
exit 1
fi
# Create snapshot for rollback
node .unity-websocket/uw snapshot create "CI Build $BUILD_NUMBER"
# Cleanup
node .unity-websocket/uw db disconnect
```
## Related Documentation
- [README.md](../../README.md) - Main plugin documentation
- [COMMANDS.md](./COMMANDS.md) - Complete CLI command reference
- [SKILL.md](../SKILL.md) - Skill documentation
- [Unity C# Package](../assets/unity-package/Editor/Database/) - Database implementation
---
**Version**: 0.7.0
**Last Updated**: 2025-11-19
**Database Version**: Migration_002 (GUID support)