# Auto Detection

GPM features the most sophisticated engine detection system in the game development industry, automatically identifying and configuring the optimal workflow for your project. This intelligent detection system eliminates manual configuration and ensures seamless integration across Unity, Godot, and Unreal Engine.

## Intelligent Engine Detection

### Multi-Engine Recognition

GPM automatically detects game engine projects by analyzing project structure and configuration files:

* **Unity**: Detects `Assets/`, `ProjectSettings/`, `Packages/manifest.json`
* **Godot**: Detects `project.godot` file and project structure
* **Unreal Engine**: Detects `*.uproject` files and `Content/` directory
* **Cocos Creator**: Detects `project.json` and `assets/` directory

### Detection Confidence Levels

GPM provides confidence levels for engine detection:

* **Maximum**: Very specific indicators (e.g., `.uproject` files)
* **High**: Multiple strong indicators
* **Medium**: Some indicators present
* **Low**: Weak or few indicators
* **None**: No indicators found

## Detection Process

### Automatic Detection

```bash
# Detect engine in current directory
gpm detect

# Detect engine in specific directory
gpm detect /path/to/project

# Detect with JSON output
gpm detect --json
```

### Detection Output

```bash
Game Engine Detection
─────────────────────────────────────────
Scanned Directory: /path/to/project
─────────────────────────────────────────
✓ Unity project detected (High confidence)
  • Assets/ directory found
  • ProjectSettings/ directory found
  • Packages/manifest.json found

─────────────────────────────────────────
Unity project detected successfully
```

### JSON Output

```json
{
  "success": true,
  "directory": "/path/to/project",
  "engines": [
    {
      "name": "unity",
      "confidence": "high",
      "indicators": [
        "Assets/ directory found",
        "ProjectSettings/ directory found",
        "Packages/manifest.json found"
      ]
    }
  ],
  "message": "Unity project detected successfully"
}
```

## Engine-Specific Detection

### Unity Detection

**High Confidence Indicators:**

* `Packages/manifest.json` file
* `Assets/` directory
* `ProjectSettings/` directory

**Medium Confidence Indicators:**

* `Library/` directory
* `Logs/` directory
* `Temp/` directory

**Low Confidence Indicators:**

* `.unity` files
* `.cs` files in root

### Godot Detection

**High Confidence Indicators:**

* `project.godot` file
* `.tscn` files
* `.cs` files

**Medium Confidence Indicators:**

* `addons/` directory
* `.gd` files
* `.tres` files

**Low Confidence Indicators:**

* `.import` files
* `.tmp` files

### Unreal Engine Detection

**High Confidence Indicators:**

* `*.uproject` files
* `Content/` directory
* `Config/` directory

**Medium Confidence Indicators:**

* `Source/` directory
* `Plugins/` directory
* `.uplugin` files

**Low Confidence Indicators:**

* `.uasset` files
* `.umap` files

### Cocos Creator Detection

**High Confidence Indicators:**

* `project.json` file
* `assets/` directory
* `settings/` directory

**Medium Confidence Indicators:**

* `build/` directory
* `library/` directory
* `.meta` files

**Low Confidence Indicators:**

* `.cc` files
* `.js` files

## Multiple Engine Detection

### Nested Projects

GPM can detect multiple engine projects in a single directory:

```bash
# Detect multiple projects
gpm detect /path/to/workspace

# Output shows all detected engines
Game Engine Detection
─────────────────────────────────────────
Scanned Directory: /path/to/workspace
─────────────────────────────────────────
✓ Unity project detected (High confidence)
  • Assets/ directory found
  • ProjectSettings/ directory found
  • Packages/manifest.json found

✓ Godot project detected (High confidence)
  • project.godot file found
  • .tscn files found

─────────────────────────────────────────
2 projects detected successfully
```

### Workspace Organization

GPM works best with organized workspace structures:

```
workspace/
├── unity-project/
│   ├── Assets/
│   ├── ProjectSettings/
│   └── Packages/
├── godot-project/
│   ├── project.godot
│   └── scenes/
└── unreal-project/
    ├── Project.uproject
    └── Content/
```

## Detection Configuration

### Enable/Disable Detection

```bash
# Enable automatic detection (default)
gpm config set engine.detect true

# Disable automatic detection
gpm config set engine.detect false
```

### Detection Behavior

When detection is enabled:

* GPM automatically detects engines before package operations
* Appropriate engine-specific workflows are applied
* Configuration is optimized for the detected engine

When detection is disabled:

* Manual engine specification is required
* Use `--engine` flag to specify engine type
* No automatic configuration is applied

## Manual Engine Specification

### Override Detection

```bash
# Force Unity engine
gpm add com.unity.analytics --engine unity

# Force Godot engine
gpm add com.company.addon --engine godot

# Force Unreal Engine
gpm add com.company.plugin --engine unreal
```

### Engine-Specific Commands

```bash
# Unity-specific operations
gpm add com.unity.analytics --engine unity
gpm install --engine unity
gpm list --engine unity

# Godot-specific operations (planned)
gpm add com.company.addon --engine godot
gpm install --engine godot
gpm list --engine godot

# Unreal Engine-specific operations (planned)
gpm add com.company.plugin --engine unreal
gpm install --engine unreal
gpm list --engine unreal
```

## Detection Use Cases

### Development Workflow

```bash
# 1. Navigate to project
cd /path/to/project

# 2. Detect engine automatically
gpm detect

# 3. Add packages (engine auto-detected)
gpm add com.unity.analytics

# 4. List packages
gpm list
```

### CI/CD Integration

```bash
# 1. Detect projects in CI
gpm detect --json > detection-results.json

# 2. Process detection results
gpm detect --json | jq '.engines[] | .name'

# 3. Install packages based on detected engine
gpm install
```

### Multi-Project Management

```bash
# 1. Detect all projects in workspace
gpm detect /workspace

# 2. Process each project individually
for project in $(gpm detect /workspace --json | jq -r '.engines[] | .name'); do
  echo "Processing $project project"
  gpm install --engine $project
done
```

## Detection Best Practices

### Project Organization

```bash
# Organize projects by engine
mkdir -p /workspace/unity-projects
mkdir -p /workspace/godot-projects
mkdir -p /workspace/unreal-projects

# Detect each engine type
gpm detect /workspace/unity-projects
gpm detect /workspace/godot-projects
gpm detect /workspace/unreal-projects
```

### Detection Validation

```bash
# Always verify detection results
gpm detect --json | jq '.engines[0].confidence'

# Check for specific engine
gpm detect --json | jq '.engines[] | select(.name == "unity")'
```

### Directory Structure

```bash
# Use clear project structure
/workspace/
├── unity-project/
│   ├── Assets/
│   ├── ProjectSettings/
│   └── Packages/
├── godot-project/
│   ├── project.godot
│   └── scenes/
└── unreal-project/
    ├── Project.uproject
    └── Content/
```

## Troubleshooting Detection

### Common Detection Issues

#### No Engine Detected

```bash
# Problem: No engine detected
gpm detect
# Output: No game engine projects detected

# Solutions:
# 1. Check project structure
ls -la

# 2. Verify required files exist
ls -la Assets/ ProjectSettings/ Packages/

# 3. Use manual engine specification
gpm add com.unity.analytics --engine unity
```

#### Multiple Engines Detected

```bash
# Problem: Multiple engines detected
gpm detect
# Output: Multiple engines detected

# Solutions:
# 1. Organize projects by engine
mkdir -p unity-project godot-project

# 2. Use specific directories
gpm detect ./unity-project

# 3. Specify engine manually
gpm add com.unity.analytics --engine unity
```

#### Detection Confidence Low

```bash
# Problem: Low confidence detection
gpm detect
# Output: Unity project detected (Low confidence)

# Solutions:
# 1. Verify project structure
ls -la Assets/ ProjectSettings/

# 2. Check for required files
ls -la Packages/manifest.json

# 3. Use manual engine specification
gpm add com.unity.analytics --engine unity
```

### Debug Detection

```bash
# Get detailed detection information
gpm detect --verbose

# Check detection with JSON output
gpm detect --json

# Verify project structure
gpm detect --json | jq '.engines[0].indicators'
```

## Integration with Package Operations

### Automatic Engine Selection

GPM automatically selects the appropriate engine for package operations:

```bash
# Engine auto-detected from project
gpm add com.unity.analytics
gpm install
gpm list
gpm update
```

### Engine-Specific Workflows

Each detected engine uses optimized workflows:

* **Unity**: UPM manifest management, scoped registry configuration
* **Godot**: Addon directory management, project.godot integration
* **Unreal Engine**: Plugin directory management, .uproject integration

## Future Enhancements

### Planned Detection Features

* **Enhanced Confidence Scoring**: More sophisticated confidence algorithms
* **Custom Detection Rules**: User-defined detection criteria
* **Detection Caching**: Cache detection results for performance
* **Multi-Engine Projects**: Support for projects using multiple engines

### Detection API

```bash
# Planned: Detection API endpoints
gpm detect --api
gpm detect --export-rules
gpm detect --import-rules
```

## See Also

* [Engine Support Overview](/multi-engine-support/engines.md) - Multi-engine support
* [Unity Integration](/multi-engine-support/engines/unity.md) - Unity-specific workflows
* [Godot Integration](/multi-engine-support/engines/godot.md) - Godot-specific workflows
* [Unreal Engine Integration](/multi-engine-support/engines/unreal.md) - Unreal Engine workflows
* [Package Management](/cli-reference/cli/package-management.md) - Advanced package operations


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gpm.sh/multi-engine-support/engines/auto-detection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
