|
19 | 19 | 2. [Module Structure Analysis](#module-structure-analysis) |
20 | 20 | 3. [Creating Modules Manually](#creating-modules-manually) |
21 | 21 | 4. [Creating Modules with IDE](#creating-modules-with-ide) |
22 | | -5. [Module Dependencies](#module-dependencies) |
23 | | -6. [Best Practices](#best-practices) |
24 | | -7. [Common Issues and Solutions](#common-issues-and-solutions) |
25 | | -8. [References](#references) |
26 | | -9. [Contributing](#contributing) |
| 22 | +5. [Migrating Modules](#migrating-modules) |
| 23 | +6. [Module Dependencies](#module-dependencies) |
| 24 | +7. [Best Practices](#best-practices) |
| 25 | +8. [Common Issues and Solutions](#common-issues-and-solutions) |
| 26 | +9. [References](#references) |
| 27 | +10. [Contributing](#contributing) |
27 | 28 |
|
28 | 29 | ## What is an Unreal Module |
29 | 30 |
|
@@ -89,6 +90,14 @@ FirstModule/Source/ |
89 | 90 | │ ├── ManualExposed.cpp |
90 | 91 | │ ├── ManualInternal.cpp |
91 | 92 | │ └── ManualInternal.h # Internal implementation |
| 93 | +├── Migrate/ # Migrated module (example) |
| 94 | +│ ├── Migrate.Build.cs |
| 95 | +│ ├── Public/ |
| 96 | +│ │ ├── Migrate.h |
| 97 | +│ │ └── MigrateActor.h |
| 98 | +│ └── Private/ |
| 99 | +│ ├── Migrate.cpp |
| 100 | +│ └── MigrateActor.cpp |
92 | 101 | └── FirstModule/ # Main game module |
93 | 102 | ├── FirstModule.Build.cs |
94 | 103 | ├── FirstModule.cpp |
@@ -383,6 +392,180 @@ IMPLEMENT_MODULE(FAutoModule, Auto) |
383 | 392 | <img width="100%" src="https://github.com/user-attachments/assets/750c4cd3-78c8-41cd-a476-38550d93a4a3"> |
384 | 393 | 7. **Click OK** |
385 | 394 |
|
| 395 | +## Migrating Modules |
| 396 | + |
| 397 | +Sometimes you need to move or migrate an existing module from one project to another. This process involves copying the module files and updating the target project's configuration. The **Migrate** module in this project demonstrates how an external module can be integrated. |
| 398 | + |
| 399 | +> **📝 Migration Note:** |
| 400 | +> Module migration is useful when you want to: |
| 401 | +> - Share modules between different projects |
| 402 | +> - Move modules from an experimental project to production |
| 403 | +> - Reuse existing functionality in new projects |
| 404 | +> - Backup and restore specific modules |
| 405 | +
|
| 406 | +### Step 1: Copy the Module Folder |
| 407 | + |
| 408 | +The first step is to copy the entire module folder from the source project: |
| 409 | + |
| 410 | +1. **Open File Explorer** and navigate to the source project's `Source/` directory |
| 411 | +2. **Locate the module** you want to migrate (in this case, it's the `Migrate` module) |
| 412 | +3. **Copy the entire module folder** including all subdirectories and files |
| 413 | + |
| 414 | +``` |
| 415 | +SourceProject/Source/ |
| 416 | +└── Migrate/ # Copy this entire folder |
| 417 | + ├── Migrate.Build.cs |
| 418 | + ├── Public/ |
| 419 | + │ ├── Migrate.h |
| 420 | + │ └── MigrateActor.h |
| 421 | + └── Private/ |
| 422 | + ├── Migrate.cpp |
| 423 | + └── MigrateActor.cpp |
| 424 | +``` |
| 425 | + |
| 426 | +### Step 2: Paste to Target Project |
| 427 | + |
| 428 | +Paste the copied module folder to the target project: |
| 429 | + |
| 430 | +1. **Navigate to the target project's `Source/` directory** |
| 431 | +2. **Paste the module folder** at the same hierarchy level as existing modules like `Auto` and `Manual` |
| 432 | + |
| 433 | +``` |
| 434 | +TargetProject/Source/ |
| 435 | +├── Auto/ # Existing module |
| 436 | +├── Manual/ # Existing module |
| 437 | +├── Migrate/ # ✅ Newly migrated module |
| 438 | +│ ├── Migrate.Build.cs |
| 439 | +│ ├── Public/ |
| 440 | +│ │ ├── Migrate.h |
| 441 | +│ │ └── MigrateActor.h |
| 442 | +│ └── Private/ |
| 443 | +│ ├── Migrate.cpp |
| 444 | +│ └── MigrateActor.cpp |
| 445 | +└── FirstModule/ # Main game module |
| 446 | +``` |
| 447 | + |
| 448 | +### Step 3: Update Target Project Configuration |
| 449 | + |
| 450 | +After copying the files, you need to register the migrated module in the target project: |
| 451 | + |
| 452 | +#### Update .uproject File |
| 453 | + |
| 454 | +Add the new module to `FirstModule.uproject`: |
| 455 | + |
| 456 | +```json |
| 457 | +{ |
| 458 | + "FileVersion": 3, |
| 459 | + "EngineAssociation": "5.6", |
| 460 | + "Modules": [ |
| 461 | + { |
| 462 | + "Name": "FirstModule", |
| 463 | + "Type": "Runtime", |
| 464 | + "LoadingPhase": "Default" |
| 465 | + }, |
| 466 | + { |
| 467 | + "Name": "Auto", |
| 468 | + "Type": "Runtime", |
| 469 | + "LoadingPhase": "Default" |
| 470 | + }, |
| 471 | + { |
| 472 | + "Name": "Manual", |
| 473 | + "Type": "Runtime", |
| 474 | + "LoadingPhase": "Default" |
| 475 | + }, |
| 476 | + { |
| 477 | + "Name": "Migrate", // ✅ Add this entry |
| 478 | + "Type": "Runtime", |
| 479 | + "LoadingPhase": "Default" |
| 480 | + } |
| 481 | + ] |
| 482 | +} |
| 483 | +``` |
| 484 | + |
| 485 | +#### Update Target.cs Files |
| 486 | + |
| 487 | +Add the module name to both `FirstModule.Target.cs` and `FirstModuleEditor.Target.cs`: |
| 488 | + |
| 489 | +**FirstModule.Target.cs:** |
| 490 | +```csharp |
| 491 | +private void RegisterModulesCreatedByRider() |
| 492 | +{ |
| 493 | + ExtraModuleNames.AddRange(["Auto", "Manual", "Migrate"]); // ✅ Add "Migrate" |
| 494 | +} |
| 495 | +``` |
| 496 | + |
| 497 | +**FirstModuleEditor.Target.cs:** |
| 498 | +```csharp |
| 499 | +private void RegisterModulesCreatedByRider() |
| 500 | +{ |
| 501 | + ExtraModuleNames.AddRange(["Auto", "Manual", "Migrate"]); // ✅ Add "Migrate" |
| 502 | +} |
| 503 | +``` |
| 504 | + |
| 505 | +### Step 4: Regenerate Project Files |
| 506 | + |
| 507 | +After updating the configuration files: |
| 508 | + |
| 509 | +1. **Close your IDE** (Rider/Visual Studio) |
| 510 | +2. **Right-click on `FirstModule.uproject`** → Select "Generate Visual Studio Project Files" |
| 511 | +3. **Wait for generation to complete** |
| 512 | +4. **Reopen the project** in your IDE |
| 513 | + |
| 514 | +### Step 5: Verify Migration |
| 515 | + |
| 516 | +To confirm the migration was successful: |
| 517 | + |
| 518 | +1. **Check that the module compiles** without errors |
| 519 | +2. **Verify module loading** in the UE Editor logs: |
| 520 | + ``` |
| 521 | + LogTemp: Warning: MigrateActor::AMigrateActor |
| 522 | + ``` |
| 523 | +3. **Test module functionality** by using its classes in other modules or Blueprints |
| 524 | + |
| 525 | +### Migration Best Practices |
| 526 | + |
| 527 | +#### ✅ Do: |
| 528 | +- **Keep module self-contained**: Ensure the module doesn't have hard-coded dependencies on the source project |
| 529 | +- **Update dependencies carefully**: Check if the target project has all required dependencies |
| 530 | +- **Test thoroughly**: Verify all functionality works in the new environment |
| 531 | +- **Maintain API consistency**: Keep public interfaces stable for easier migration |
| 532 | + |
| 533 | +#### ❌ Don't: |
| 534 | +- **Copy system-specific files**: Don't migrate `Intermediate/` or `Binaries/` folders |
| 535 | +- **Ignore dependencies**: Make sure all required modules exist in the target project |
| 536 | +- **Skip regeneration**: Always regenerate project files after migration |
| 537 | +- **Assume compatibility**: Different UE versions might require code adjustments |
| 538 | + |
| 539 | +### Common Migration Issues |
| 540 | + |
| 541 | +#### Issue 1: Missing Dependencies |
| 542 | +**Symptoms**: Compilation errors about missing includes or undefined classes |
| 543 | +**Solution**: Ensure all dependency modules exist in the target project or update `Build.cs` |
| 544 | + |
| 545 | +#### Issue 2: API Mismatch |
| 546 | +**Symptoms**: Linker errors or undefined symbols |
| 547 | +**Solution**: Verify the `MIGRATE_API` macro is correctly defined and used |
| 548 | + |
| 549 | +#### Issue 3: Module Not Loading |
| 550 | +**Symptoms**: Module doesn't appear in the modules list |
| 551 | +**Solution**: Double-check `.uproject` and `Target.cs` entries, then regenerate project files |
| 552 | + |
| 553 | +### Advanced Migration Scenarios |
| 554 | + |
| 555 | +#### Cross-Version Migration |
| 556 | +When migrating between different UE versions: |
| 557 | +1. **Check API changes** in the UE documentation |
| 558 | +2. **Update deprecated functions** to their modern equivalents |
| 559 | +3. **Verify Build.cs compatibility** with the target UE version |
| 560 | + |
| 561 | +#### Dependency Chain Migration |
| 562 | +When migrating a module that depends on other custom modules: |
| 563 | +1. **Migrate dependencies first** in the correct order |
| 564 | +2. **Update Build.cs dependencies** to match the target project structure |
| 565 | +3. **Test the entire dependency chain** after migration |
| 566 | + |
| 567 | +Module migration is a powerful feature that enables code reuse across projects and helps maintain a modular architecture. The **Migrate** module in this project serves as a practical example of how external modules can be seamlessly integrated into existing projects. |
| 568 | + |
386 | 569 | ## Module Dependencies |
387 | 570 |
|
388 | 571 | > **📝 Naming Convention Note:** |
|
0 commit comments