アンリアる! C++入門編 ~対話形式で学ぶUnreal Engine~
BOOTHでUnreal Engine C++入門書を販売していますUnreal Engine上でC++を使って開発するために必要となる基礎知識を一冊の本にまとめた本です。 対話形式によるわかりやすい説明を目指しました。無料の試し読みも可能ですので、ぜひ読んでみてください!
[UE5] Debugging Packaged Projects

Packaging an Unreal Engine project allows you to run the application you created for the target platform.
Packaging a project includes the optimization and the transformation of the data format for the target platform.
Therefore, we sometimes face with the problem when packaged on these phases.
You can debug in the editor, by simply creating a C++ project and selecting "DebugGame Editor.
However, we can not follow same method for the packaged projects.

This article explains how to debug packaged projects by using Visual C++.

Prerequirement

Unreal Engine Version 5.1
OS Windows
Target Platform Windows

Procedure

Create C++ Project

Right click on the Unreal Engine project file (the .uproject file) and execute [Generate Visual Studio project files].
Open the Visual C++ solution file (.sln file) and build the project.
At this time, select [DebugGame Editor] for the solution configuration.

To create a C++ project, please also refer to the following article.

[UE5] How to Introduce C++
This article explains how to introduce C++ in the Unreal Engine and how to add C++ header and source files (C++ classes).

Configure Project Packaging Settings

Open your Unreal Engine project file.
Click on [Platforms] at the top of the screen and navigate to [Windows] in the menu.
From the menu item [BINARY CONFIGURATION], select [DebugGame].

Configuration for Packaging Project

Package Project

Click on [Platforms] at the top of the screen and navigate to [Windows] in the menu.
From the [CONTENT MANAGEMENT] menu, select [Package Project].

Package Project

A window will open to specify where to save the generated files after the build.
Once the location is specified, the project start packaging.
If the project is successfully packaged, an executable file Windows/DebugPackagedProject/Binaries/Win64/-Win64-DebugGame.exe will be generated.

If the build fails, an error message will appear in the [Output Log], so check and fix the error.

Run the Executable File

Run the executable file generated by the project packaging will launch the application.

Attach to the Application Process

Attach to the process of the launched application.
Open the Visual C++ solution file and run [Debug] > [Attach to Process].

Attach to the Process Step 1

A new window will be created.
Select the name of the process you want to attach.
The name of the process is the same as the name of the executable file.

Attach to the Process Step 2

Debugging

Once the process is attached, you can debug on Visual C++.
You will be able to debug by using breakpoints and so on.

Debugging

Summary

This article explained how to debug a packaged project.
We can often see that the behavior will be changed after packaging even for the same implementation.
If we implement by using C++, the packaged application sometimes does not work correctly.
Also, debugging the packaged application is difficult.
We hope that this article will help you to improve the efficiency of debugging packaged applications.