54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
---
|
||
title: 打包项目的Debug方法
|
||
date: 2022-08-24 13:30:08
|
||
excerpt:
|
||
tags: debug
|
||
rating: ⭐
|
||
---
|
||
## 参考视频
|
||
https://www.youtube.com/watch?v=CmWbMT4WAhU
|
||
|
||
## Shipping模式保存日志文件
|
||
1. 在您的 {projectname}.Target.cs 文件的 contrsutor 中,添加以下行: `bUseLoggingInShipping = true;`。
|
||
2. 根据源码版与官方编译版有额外的2个设置:
|
||
1. 源码版:增加`BuildEnvironment = TargetBuildEnvironment.Unique`。
|
||
2. 官方编译版:增加`bOverrideBuildEnvironment = true;`。
|
||
|
||
比如:
|
||
```c#
|
||
public class GameTarget : TargetRules
|
||
{
|
||
public GameTarget(TargetInfo Target) : base(Target)
|
||
{
|
||
Type = TargetType.Game;
|
||
|
||
// enable logs and debugging for Shipping builds
|
||
if (Configuration == UnrealTargetConfiguration.Shipping)
|
||
{
|
||
BuildEnvironment = TargetBuildEnvironment.Unique;
|
||
bUseChecksInShipping = true;
|
||
bUseLoggingInShipping = true;
|
||
}
|
||
|
||
ExtraModuleNames.AddRange( new string[] { "Game" } );
|
||
}
|
||
}
|
||
|
||
```
|
||
|
||
## Debug打包后的游戏
|
||
1. 以DebugGame模式进行打包。
|
||
2. 运行游戏,并在任务管理器中找到该游戏进程。
|
||
3. 右键选择调试。
|
||
|
||
或者可以在VS里手动选择附加进程。
|
||
|
||
## 调试相关命令行
|
||
1. 如果想在一开始就进行附加,可以在游戏运行方式中加入`-waitforattach`。
|
||
2. 在游戏运行方式中加入`-log`就可以在开始时显示log。
|
||
|
||
## 生成调试符号
|
||
**Settings -> Packaging Settings -> Project**中勾选Include Debug Files选项就可以生成PDB文件。
|
||
|
||
## UE4Launcher
|
||
查里鹏开发的工具,可以方便启动UE工程:https://github.com/hxhb/UE4Launcher |