# Unity Editor Toolkit - GameObject & Hierarchy Commands Complete reference for GameObject manipulation and hierarchy query commands. **Last Updated**: 2025-01-13 --- ## cd && node .unity-websocket/uw go find Find GameObject by name or hierarchical path. **Usage:** ```bash cd && node .unity-websocket/uw go find [options] ``` **Arguments:** ``` 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 Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Find GameObject by name cd && node .unity-websocket/uw go find "Player" # Find with full hierarchy path cd && node .unity-websocket/uw go find "Environment/Terrain/Trees" # Include component information cd && node .unity-websocket/uw go find "Player" --with-components # Get all details in JSON format cd && node .unity-websocket/uw go find "Enemy" --full --json ``` --- ## cd && node .unity-websocket/uw go create Create new GameObject. **Usage:** ```bash cd && node .unity-websocket/uw go create [options] ``` **Arguments:** ``` Name for the new GameObject ``` **Options:** ``` -p, --parent Parent GameObject name or path --primitive Create primitive: cube, sphere, cylinder, capsule, plane, quad --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Create empty GameObject cd && node .unity-websocket/uw go create "NewObject" # Create with parent cd && node .unity-websocket/uw go create "Child" --parent "Parent" # Create primitive cd && node .unity-websocket/uw go create "MyCube" --primitive cube # Create nested object cd && node .unity-websocket/uw go create "Enemy" --parent "Enemies/Group1" ``` --- ## cd && node .unity-websocket/uw go destroy Destroy GameObject. **Usage:** ```bash cd && node .unity-websocket/uw go destroy [options] ``` **Arguments:** ``` GameObject name or path to destroy ``` **Options:** ``` --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Destroy GameObject cd && node .unity-websocket/uw go destroy "OldObject" # Destroy nested GameObject cd && node .unity-websocket/uw go destroy "Enemies/Enemy1" # Get JSON response cd && node .unity-websocket/uw go destroy "Temp" --json ``` --- ## cd && node .unity-websocket/uw go set-active Set GameObject active state. **Usage:** ```bash cd && node .unity-websocket/uw go set-active [options] ``` **Arguments:** ``` GameObject name or path Active state: true or false ``` **Options:** ``` --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Activate GameObject cd && node .unity-websocket/uw go set-active "Player" true # Deactivate GameObject cd && node .unity-websocket/uw go set-active "Enemy" false # Set nested GameObject state cd && node .unity-websocket/uw go set-active "UI/Menu/Settings" false ``` --- ## cd && node .unity-websocket/uw go set-parent Set or remove parent of GameObject. **Usage:** ```bash cd && node .unity-websocket/uw go set-parent [parent] [options] ``` **Arguments:** ``` GameObject name or path [parent] Parent GameObject name (omit to remove parent) ``` **Options:** ``` --world-position-stays Keep world position (default: true) --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Set parent (attach "Weapon" to "Player") cd && node .unity-websocket/uw go set-parent "Weapon" "Player" # Remove parent (detach to root) cd && node .unity-websocket/uw go set-parent "Weapon" # Set parent without keeping world position cd && node .unity-websocket/uw go set-parent "Child" "Parent" --world-position-stays false # Reparent nested object cd && node .unity-websocket/uw go set-parent "UI/Menu" "Canvas" ``` --- ## cd && node .unity-websocket/uw go get-parent Get parent information of GameObject. **Usage:** ```bash cd && node .unity-websocket/uw go get-parent [options] ``` **Arguments:** ``` GameObject name or path ``` **Options:** ``` --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Get parent info cd && node .unity-websocket/uw go get-parent "Weapon" # Check if object has parent cd && node .unity-websocket/uw go get-parent "Player" --json # Get parent of nested object cd && node .unity-websocket/uw go get-parent "Enemies/Enemy1" ``` --- ## cd && node .unity-websocket/uw go get-children Get children of GameObject. **Usage:** ```bash cd && node .unity-websocket/uw go get-children [options] ``` **Arguments:** ``` GameObject name or path ``` **Options:** ``` -r, --recursive Get all descendants (not just direct children) --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # Get direct children cd && node .unity-websocket/uw go get-children "Player" # Get all descendants recursively cd && node .unity-websocket/uw go get-children "Player" --recursive # Get children with JSON output cd && node .unity-websocket/uw go get-children "Canvas" --json # Count nested objects cd && node .unity-websocket/uw go get-children "Environment" --recursive --json ``` --- ## cd && node .unity-websocket/uw hierarchy Query Unity GameObject hierarchy with tree visualization. **Usage:** ```bash cd && 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 Limit hierarchy depth (e.g., 2 for 2 levels) -f, --filter Filter GameObjects by name (case-insensitive) -c, --with-components Include component information for each GameObject --json Output in JSON format --timeout Connection timeout in milliseconds (default: 30000) -h, --help Display help for command ``` **Examples:** ```bash # View full hierarchy cd && node .unity-websocket/uw hierarchy # Show only root GameObjects cd && node .unity-websocket/uw hierarchy --root-only # Limit depth to 2 levels cd && node .unity-websocket/uw hierarchy --depth 2 # Filter by name cd && node .unity-websocket/uw hierarchy --filter "enemy" # Show only active GameObjects with components cd && node .unity-websocket/uw hierarchy --active-only --with-components # Get JSON output cd && 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 Unity WebSocket port (overrides auto-detection) -h, --help Display help for command ``` **Examples:** ```bash # Check CLI version cd && node .unity-websocket/uw --version # Enable verbose logging cd && node .unity-websocket/uw --verbose hierarchy # Use specific port cd && 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 && 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