UE工具链配置与开发技巧

工欲善其事,必先利其器!Mastering the right tools can elevate development efficiency to a new level.
This article is a compilation of notes I usually keep in notes about the UE toolchain and some configuration and usage tips for tools using UE. Future content in this area will also be included in this article.
Below are some standalone articles I previously wrote about the UE toolchain or relevant extensions:

Generate Documentation from UE Code Using Doxygen

Recently, I used doxygen to generate documentation for the Runtime/Engine module from the Unreal Engine source code. The exported chm file is already 700MB (mainly due to various graphs), quite large.
Note: Before generating documentation from the UE source code using doxygen, remember to remove all UE macros from the .h/.hpp files in the source code (I wrote a simple program to handle this), otherwise, the generated output may have issues (e.g., function names may disappear, showing UFUNCTION instead, or member variables may disappear, showing UPROPERTY). Mainly, you just need to remove the following macros.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
"UFUNCTION",  
"DEPRECATED",
"UCLASS",
"UINTERFACE",
"UPROPERTY",
"GENERATED_BODY()",
"GENERATED_UCLASS_BODY()",
"GENERATED_INTERFACE_BODY()"
```
Using `sed`, the command would be as follows:

```bash
# Remove macros from the source files and save
$ sed -i -e /UFUNCTION/d -e /DEPRECATED/d -e /UCLASS/d -e /UINTERFACE/d -e /UPROPERTY/d -e /GENERATED_BODY/d -e /GENERATED_UCLASS_BODY/d -e /GENERATED_INTERFACE_BODY/d ${filename}
# Example Actor.h
$ sed -i -e /UFUNCTION/d -e /DEPRECATED/d -e /UCLASS/d -e /UINTERFACE/d -e /UPROPERTY/d -e /GENERATED_BODY/d -e /GENERATED_UCLASS_BODY/d -e /GENERATED_INTERFACE_BODY/d Actor.h
```

## Parameters for UnrealVersionSelector

- `-register`: Add the current directory to the list of installations
- `-fileassociations`: Update all the settings.
- `-switchversion`: Associate with an engine label
- `-switchversionsilent`: Associate with a specific engine label
- `-editor`: Open a project with the editor
- `-projectlist`: Open the editor
- `-game`: Play a game using the editor executable
- `-projectfiles`: Generate Visual Studio project files

## Parameters for UnrealPak
Parameters supported by UE4.22.3 UnrealPak:

```txt
Usage:
UnrealPak <PakFilename> -Test
UnrealPak <PakFilename> -List [-ExcludeDeleted]
UnrealPak <PakFilename> <GameUProjectName> <GameFolderName> -ExportDependencies=<OutputFileBase> -NoAssetRegistryCache -ForceDependsGathering
UnrealPak <PakFilename> -Extract <ExtractDir> [-Filter=<filename>]
UnrealPak <PakFilename> -Create=<ResponseFile> [Options]
UnrealPak <PakFilename> -Dest=<MountPoint>
UnrealPak <PakFilename> -Repack [-Output=Path] [-ExcludeDeleted] [Options]
UnrealPak <PakFilename1> <PakFilename2> -diff
UnrealPak <PakFolder> -AuditFiles [-OnlyDeleted] [-CSV=<filename>] [-order=<OrderingFile>] [-SortByOrdering]
UnrealPak <PakFilename> -WhatsAtOffset [offset1] [offset2] [offset3] [...]
UnrealPak <PakFolder> -GeneratePIXMappingFile -OutputPath=<Path>
UnrealPak -TestEncryption
Options:
-blocksize=<BlockSize>
-bitwindow=<BitWindow>
-compress
-encrypt
-order=<OrderingFile>
-diff (requires 2 filenames first)
-enginedir (specify engine dir for when using ini encryption configs)
-projectdir (specify project dir for when using ini encryption configs)
-encryptionini (specify ini base name to gather encryption settings from)
-extracttomountpoint (Extract to mount point path of pak file)
-encryptindex (encrypt the pak file index, making it unusable in unrealpak without supplying the key)
-compressionformat[s]=<Format[,format2,...]> (set the format(s) to compress with, falling back on failures)
```
Directly executing the packaging command in the editor (UE4.22.3, specifying encryption here):

```txt
"D:\UnrealEngine\UE_4.22\Engine\Binaries\Win64\UnrealPak.exe" "C:\Users\Administrator\Documents\Unreal Projects\Mobile422\Saved\StagedBuilds\WindowsNoEditor\Mobile422\Content\Paks\Mobile422-WindowsNoEditor.pak"
-create="C:\Users\Administrator\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.22\PakList_Mobile422-WindowsNoEditor.txt"
-cryptokeys="C:\Users\Administrator\Documents\Unreal Projects\Mobile422\Saved\Cooked\WindowsNoEditor\Mobile422\Metadata\Crypto.json"
-order="C:\Users\Administrator\Documents\Unreal Projects\Mobile422\Build\WindowsNoEditor\FileOpenOrder\CookerOpenOrder.log"
-encryptindex
-patchpaddingalign=2048
-compressionformats= "C:\Users\Administrator\Documents\Unreal Projects\Mobile422\Mobile422.uproject"
-multiprocess
-abslog="C:\Users\Administrator\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.22\UnrealPak-Mobile422-WindowsNoEditor-2020.02.11-18.48.15.txt"
```
The structure of the `cryptokeys` parameter is:

```json
{
"$types":{
"UnrealBuildTool.EncryptionAndSigning+CryptoSettings, UnrealBuildTool, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null":"1",
"UnrealBuildTool.EncryptionAndSigning+EncryptionKey, UnrealBuildTool, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null":"2",
"UnrealBuildTool.EncryptionAndSigning+SigningKeyPair, UnrealBuildTool, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null":"3",
"UnrealBuildTool.EncryptionAndSigning+SigningKey, UnrealBuildTool, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null":"4"
},
"$type":"1",
"EncryptionKey":{
"$type":"2",
"Name":"Embedded",
"Guid":"00000000-0000-0000-0000-000000000000",
"Key":"+c0unLTPVpJ8E2MAs3SrUh/bRHasFOvq1kKXnmZBZcw="
},
"SigningKey":{
"$type":"3",
"PublicKey":{
"$type":"4",
"Exponent":"AQAB",
"Modulus":"m48Hq1rQKqljGUBCVku+qxFoa1oVBXghOWKSPArwl9uixba6pxlgqyV/BINWRYQMzgcdKPvGgusRIlalPqEEQB9XibCqJahUpxszoNkhH33cWSpMKZ8XWNmnvAZvtebpqtJYVP1ebqNGvCEm+e54dsxvRJJGmcOB6Wi36/l4c9/+zgNF5BZQItOlDc8OCYlttAvDhgExDow4leNuU/nBh12rcKD4P0KmIYdPzFBYgTe18DyJ12GKf2rStFF9VDlTsp+Gl7ZejPzQ7/CsX0eSHHplsZjjCB6mlmBStFOY7OWMLS/pnYAQ6Ywnaf+tBNz4Fd9eBBxwD0Vn+dU4YDxEJYvZuVkOqyio581jHn5U7rjTofzTyHvy5tzWuYF52R2dGkcTBgjkbmE0Z6nkZ2TdPEog15eZClsHHMseyzhBa3LCC2nmnvZqppV4+Ijj5e1XKEobPOgVZMejXNukW1dzfX9gMf1NrOD2KX2cnyPT6IvP6zu5Cztiy3rVtBiDtQIaQnaCsix8t0+oh5aqzhj6GrblcYs1JX/uy0OYO+hO/yTLET378TehhRjYbnHQsS2PBqBVM6i7hK7xT1TxuUE5oJYJULDWmOn9AZKmnzkx+VyQgmqmNA/L0vJqOhsDvvA29UGNEn5junydqkQlLP4OovlZcoic2R/tYPFcwMKPp68="
},
"PrivateKey":{
"$type":"4",
"Exponent":"URhnOOSPQp7VG5FxGq2wLQ+k3FJUQEy+GWOYxbk8KKNwtbt/Fy+agBMtuZOuLKmhjWrIpU0+i78rM7cFur3qXI5TUFZ1Jj2eIhxrphoKnu99FmcLEIICtFp0Y/rbyv1RmBSvh9E+kMebvw2KGlVVl8JNhRnyZtdHEoWN7YV+zeSNuGDh8h6pJkN8b15PuXZhQw9RKa3WRsNy/3PCVkNILsOI7L+VZTQ3Zl0q3DghlaHNZlkeyLp/uSnArayUdWlTBq8H0ZtyaAlgBhFNnh/CkQFenpnz2EKSO4aMGo6NkIjbYEYoK5t119z0S56JbzGA71iDqW3VxK5KxZcDLItU8yGp7zi6SPAJXvUxg/8rnXRZ/nm+8KVLwi3Itog8DWYR7zx4weNd2Tx4JvHx+FatLnM3ut6yiUiaW6uL0Zg+yLg1PXy5bEwlAlke/9c/Z7gyY+cLQVMv525LgMQQDje/wNaQT2QosN5Cum+5jPq/0BYB4kXeotvASS2FLRJyo43JjmyfP6oQLOtSNDqbf1jl4JtjoCXBFAZKz6cR4RP1CWst4mMLUJqgOjQeSdd5ihdYZErKPzlLpghQixC/dx3W0ISzkp9b22Ee302bHQHwio+4Gc8B2e/Iabd8TQZuq8LY9BSrllHda8NsG3TFt3hEC+fjdhbz5ur4nd1xgtPtP00=",
"Modulus":"m48Hq1rQKqljGUBCVku+qxFoa1oVBXghOWKSPArwl9uixba6pxlgqyV/BINWRYQMzgcdKPvGgusRIlalPqEEQB9XibCqJahUpxszoNkhH33cWSpMKZ8XWNmnvAZvtebpqtJYVP1ebqNGvCEm+e54dsxvRJJGmcOB6Wi36/l4c9/+zgNF5BZQItOlDc8OCYlttAvDhgExDow4leNuU/nBh12rcKD4P0KmIYdPzFBYgTe18DyJ12GKf2rStFF9VDlTsp+Gl7ZejPzQ7/CsX0eSHHplsZjjCB6mlmBStFOY7OWMLS/pnYAQ6Ywnaf+tBNz4Fd9eBBxwD0Vn+dU4YDxEJYvZuVkOqyio581jHn5U7rjTofzTyHvy5tzWuYF52R2dGkcTBgjkbmE0Z6nkZ2TdPEog15eZClsHHMseyzhBa3LCC2nmnvZqppV4+Ijj5e1XKEobPOgVZMejXNukW1dzfX9gMf1NrOD2KX2cnyPT6IvP6zu5Cztiy3rVtBiDtQIaQnaCsix8t0+oh5aqzhj6GrblcYs1JX/uy0OYO+hO/yTLET378TehhRjYbnHQsS2PBqBVM6i7hK7xT1TxuUE5oJYJULDWmOn9AZKmnzkx+VyQgmqmNA/L0vJqOhsDvvA29UGNEn5junydqkQlLP4OovlZcoic2R/tYPFcwMKPp68="
}
},
"bEnablePakSigning":true,
"bEnablePakIndexEncryption":true,
"bEnablePakIniEncryption":true,
"bEnablePakUAssetEncryption":true,
"bEnablePakFullAssetEncryption":true,
"bDataCryptoRequired":true,
"PakEncryptionRequired":true,
"PakSigningRequired":true,
"SecondaryEncryptionKeys":[
{
"$type":"2",
"Name":"Key1",
"Guid":"757096074E55F5FCA962949C55209CCB",
"Key":"SsukCy4DShNsMi5e9jUpMWJi5qtTA+rLeIoTHRtjM0o="
}
]
}
```
This is generated based on the settings in `Project Setting`-`Crypto`.

Common command combinations for UnrealPak:

```cpp
# Package all cooked resources under COOCKED_ASSET_FOLDER into a pak file and compress
unrealpak.exe NEW_PAK_FILE_NAME.pak -create=COOCKED_ASSET_FOLDER -compress
# Encrypt the pak, specifying a 32-bit AES key; must execute encryption -encrypt/-encryptindex/-aes whichever you choose not to do.
unrealpak.exe NEW_PAK_FILE_NAME.pak -create=COOCKED_ASSET_FOLDER -compress -encrypt -encryptindex -aes=32BIT_AES_KEY
# View the resource list in the pak
unrealpak.exe PAK_FILE_NAME.pak -list
# View the resource list in the encrypted pak
unrealpak.exe NEW_PAK_FILE_NAME.pak -list -aes=32BIT_AES_KEY
```
Related tools:
- [Online AES Encryption and Decryption Tool](https://www.sojson.com/encrypt_aes.html)
- [UnrealPakViewer](https://github.com/hxhb/UnrealPakViewer)
- [umodel](https://www.gildor.org/en/projects/umodel)

In `Project Setting`-`Project`-`Crypto`, you can choose to encrypt the project and directly generate `EncryptionKey`:

![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/ue-encrypt-project.webp)

UnrealPak is a Standalone Application, and its startup code is found in: [Engine/Source/Programs/UnrealPak/Private/UnrealPak.cpp](https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Source/Programs/UnrealPak/Private/UnrealPak.cpp).
However, it is just a forwarding function; the actual implementation code is in the engine's `ExecuteUnrealPak` function, located in [Engine/Source/Developer/PakFileUtilities/Private/PakFileUtilities.cpp](https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Source/Developer/PakFileUtilities/Private/PakFileUtilities.cpp).

UnrealPak generates a sig for pak:
> Note: In UE4.23+ engine versions, when specifying the `cryptokeys` parameter, `-sign` must be specified as well.

```bash
$ UnrealPak.exe D:\TEST_SIG.pak -create="XXXXXXX.txt" -cryptokeys="Crypto.json"
```
The Crypto.json file will be generated when you use the editor to package; it is based on the settings in `Project Setting`-`Crypto`, saved at the path:

```txt
PROJECT_DIRECTORY\Saved\Cooked\WindowsNoEditor\PROJECT_NAME\Metadata\Crypto.json
```
Make sure to replace `PROJECT_DIRECTORY` and `PROJECT_NAME` with your own.

The generation of this `Crypto.json` file occurs within the `AutomationTool`, and the relevant code is located in:

```csharp
// Source\Programs\AutomationTool\Scripts\CopyBuildToStagingDirectory.Automation.cs

/// <summary>
/// Creates a pak file using staging context (single manifest)
/// </summary>
/// <param name="Params"></param>
/// <param name="SC"></param>
private static void CreatePakUsingStagingManifest(ProjectParams Params, DeploymentContext SC)
{
LogInformation("Creating pak using staging manifest.");

DumpManifest(SC, CombinePaths(CmdEnv.LogFolder, "PrePak" + (SC.DedicatedServer ? "_Server" : "")));

var UnrealPakResponseFile = CreatePakResponseFileFromStagingManifest(SC, SC.FilesToStage.UFSFiles);

List<PakFileRules> PakRulesList = GetPakFileRules(Params, SC);

List<string> PakList = new List<string>();
List<string> FilesToRemove = new List<string>();

// Apply the pak file rules; this can remove things but will not override the pak file name
foreach (var StagingFile in UnrealPakResponseFile)
{
bool bExcludeFromPaks = false;
ApplyPakFileRules(PakRulesList, StagingFile, PakList, out bExcludeFromPaks);

if (bExcludeFromPaks)
{
FilesToRemove.Add(StagingFile.Key);
}
}

foreach (var FileToRemove in FilesToRemove)
{
UnrealPakResponseFile.Remove(FileToRemove);
}

EncryptionAndSigning.CryptoSettings PakCryptoSettings = EncryptionAndSigning.ParseCryptoSettings(DirectoryReference.FromFile(Params.RawProjectPath), SC.StageTargetPlatform.IniPlatformType);
FileReference CryptoKeysCacheFilename = FileReference.Combine(SC.MetadataDir, "Crypto.json");
PakCryptoSettings.Save(CryptoKeysCacheFilename);

List<CreatePakParams> PakInputs = new List<CreatePakParams>();
PakInputs.Add(new CreatePakParams(SC.ShortProjectName, UnrealPakResponseFile, Params.Compressed, null));
CreatePaks(Params, SC, PakInputs, PakCryptoSettings, CryptoKeysCacheFilename);
}
```

The `EncryptionAndSigning` class is defined in `UnrealBuildTool\System\EncryptionAndSigning`, where you can see the parsing of the DefaultCrypto.ini file.

## UE4: Change Number of Threads Used in Setup.bat to Speed Up Downloads
After downloading the UE4 source code, you need to run `Setup.bat` first to download dependencies before you can start generating VS project files and compiling.

However, the network environment in China is poor, and the default `Setup.bat` does not specify the number of threads (it only passes the `--prompt` argument to `GitDependencies`).

```bat
@echo off
setlocal
pushd %~dp0

rem Figure out if we should append the -prompt argument
set PROMPT_ARGUMENT=
for %%P in (%*) do if /I "%%P" == "--prompt" goto no_prompt_argument
for %%P in (%*) do if /I "%%P" == "--force" goto no_prompt_argument
set PROMPT_ARGUMENT=--prompt
:no_prompt_argument

rem Sync the dependencies...
.\Engine\Binaries\DotNET\GitDependencies.exe %PROMPT_ARGUMENT% %*
if ERRORLEVEL 1 goto error

rem Setup the git hooks...
if not exist .git\hooks goto no_git_hooks_directory
echo Registering git hooks...
echo #!/bin/sh >.git\hooks\post-checkout
echo Engine/Binaries/DotNET/GitDependencies.exe %* >>.git\hooks\post-checkout
echo #!/bin/sh >.git\hooks\post-merge
echo Engine/Binaries/DotNET\GitDependencies.exe %* >>.git\hooks\post-merge
:no_git_hooks_directory

rem Install prerequisites...
echo Installing prerequisites...
start /wait Engine\Extras\Redist\en-us\UE4PrereqSetup_x64.exe /quiet

rem Register the engine installation...
if not exist .\Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe goto :no_unreal_version_selector
.\Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe /register
:no_unreal_version_selector

rem Done!
goto :EOF

rem Error happened. Wait for a keypress before quitting.
:error
pause
```

The parameters supported by `GitDependencies.exe` are:

```cpp
Usage:
GitDependencies [options]

Options:
--all Sync all folders
--include=<X> Include binaries in folders called <X>
--exclude=<X> Exclude binaries in folders called <X>
--prompt Prompt before overwriting modified files
--force Always overwrite modified files
--root=<PATH> Set the repository directory to be synced
--threads=<N> Use N threads when downloading new files
--dry-run Print a list of outdated files and exit
--max-retries Override the maximum number of retries per file
--proxy=<user:password@url> Sets the HTTP proxy address and credentials
--cache=<PATH> Specifies a custom path for the download cache
--cache-size-multiplier=<N> Cache size as multiplier of current download
--cache-days=<N> Number of days to keep entries in the cache
--no-cache Disable caching of downloaded files

Detected settings:
Excluded folders: Mac, Android, Linux
Proxy server: none
Download cache: E:\UnrealEngine\EngineSource\UE_4.21_Source\.git\ue4-gitdeps

Default arguments can be set through the UE4_GITDEPS_ARGS environment variable.
```

Thus, we can increase the variable `PROMPT_ARGUMENT` in `Setup.bat` to include the specified number of threads (replacing N with a number):

```bat
set PROMPT_ARGUMENT=--prompt --threads=N
```

I usually set 8 threads, which can achieve around 2-3M/s...

## UE4: Clion Debug Project on MacOS
After opening the project with Clion, set debug in (`Run-Edit Configuration`):
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/clion-debug-project-build-setting-on-macos.webp)
Select the `Executable` as the executable file compiled under the `Binaries` directory of the project, and then add the parameters `-game -log`.

![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/clion-debug-ue-project-on-mac-os.webp)

## Write Code Using VSC (UE_4.18+)

Below is the official introduction from UE: [New: Visual Studio Code Supported on Windows, Mac and Linux](https://docs.unrealengine.com/en-US/Support/Builds/ReleaseNotes/4_18/index.html)

You can now use Visual Studio Code to write code on all UE4 host platforms. To use it, select "Visual Studio Code" as your preferred IDE from the editor preferences dialog or add the -vscode argument when generating project files on the command line. All platforms are also required to have the .NET Core 2.0 runtimes installed, which can be obtained from [the Microsoft .NET Core website](https://www.microsoft.com/net/core).
To use Visual Studio Code to build and debug all project types, some additional extensions are required. On all platforms, make sure the Microsoft C/C++ extension and the C# extension are installed. On Linux and Mac, the "Mono Debug" extension is required to debug C# projects, and the “LLDB Debugger” extension is required to debug C++ projects. Also, to debug C# projects, the mono runtime must be installed:

- On OS X: `brew install mono`
- On Linux:` sudo apt-get install mono-complete`

## Paste Tool for UE Blueprints
You can copy the blueprint code to [blueprintue.com](https://blueprintue.com/) (or use Tao Renxian's domestic site [blueprintue.cn](http://blueprintue.cn/) in China, but it does not support https), send the URL to others, and they can view the nodes in the blueprint, just like in the UE editor.

<!-- <iframe width="100%" scrolling=no height="500" src="https://blueprintue.com/render/-ryx9fs_" scrolling="no"></iframe> -->

<!-- <iframe src="http://blueprintue.cn/render/riztzv9g" scrolling="no" allowfullscreen></iframe> -->

## UE4: Add UE Code Snippets to VS

First, open the source version of UE in the following directory (if installed via EpicGameLauncher, it doesn’t have these, if you don’t have the source version engine, you can download it [here](VisualStudioSnippets_421.7z)):

```bash
Engine\Extras\VisualStudioSnippets
```

This directory contains numerous `*.snippet` files, which are code snippets in VS, primarily wrapping various macros of UE, making it unnecessary to type them out repeatedly when writing UE code in VS.

To import into VS: open `Tools`-`Code Snippets Manager` in VS:
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/vs-add-ue-code-snippets.webp)

Click `Import`, select the engine's directory `Engine\Extras\VisualStudioSnippets` located earlier, and import all.

To trigger in VS, press `Ctrl+K` and `Ctrl+X`, then select `My Code Snippets` to see all the imported UE `Code Snippets`.
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/vs-usage-code-snippets.webp)

## UE4: Display Object Values While Debugging in VS
Open the engine path:

```txt
Engine\Extras\VisualStudioDebugging
```

In this path, there will be a file named [UE4.natvis.zip](https://img.imzlp.com/imgs/zlp/blog/posts/12143/UE4_native.7z). Copy it to the following path in VS:

```txt
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Packages\Debugger\Visualizers
```

Then restart and initiate debugging, and you will be able to see object values in the debug window.
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/ue4-debug-in-vs-show-object-value.webp)

## VS Debugging Standalone UE Projects
When running in `Standalone` mode in UE's editor, timely attaching to processes in VS is not possible.
For example, if we want to debug the engine and project in standalone mode, directly starting under the editor will create a new process, and manually clicking `Attach to process` in VS is very inconvenient and not timely (because clicking to start while waiting to attach to the process can result in the engine already finishing loading).
Fortunately, UE provides a plugin: [UnrealVS](https://docs.unrealengine.com/en-US/Programming/Development/VisualStudioSetup/UnrealVS), and the installation program for this plugin is located in the engine's `Engine\Extras\UnrealVS` directory. Choose to install based on your VS version.
After installation, start VS and enable `View->Toolbars->UnrealVS`, and you will see it in the VS toolbar. Here, select your project:
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/UnrealVS-Plugins-Toolbar.webp)

The box below is the command line box, parameters entered here will be passed to the program at startup (for a specific introduction, see the description in [UnrealVS](https://docs.unrealengine.com/en-US/Programming/Development/VisualStudioSetup/UnrealVS)), so you can fill in the parameters such that it starts in standalone mode (you can refer to [Command-Line Arguments](https://docs.unrealengine.com/en-us/Programming/Basics/CommandLineArguments) for supported parameters):

```bash
"$(SolutionDir)$(ProjectName).uproject" -game -windowed -log -verbose
```
This way, when using F5 to start the project in VS, it will automatically attach to the process.

## UE Package: Create a Patch
- [How To Create a Patch (Platform-Agnostic)](https://docs.unrealengine.com/en-us/Engine/Deployment/HowToCreatePatch)

The most important points to note are:
You can patch a project you previously released using a versioned release. Some things to keep in mind are:

- Lock down the serialization code paths at the time of release.
- Keep the released cooked content, as the UnrealPak tool uses this to determine which content should be in the patch package file.
- At runtime, mount both pak files, with a higher priority for the patch file so any content within it is loaded first.

In summary, ensure that the resource paths from the previous packaging remain unchanged/retain the `Saved/Cooked` directory from the last package version (because the created patch detects differences in resources with the last cooked project using UnrealPak), and at runtime, the patch file `*0_P.pak` should be loaded with higher priority, with larger numbers having higher load priority.
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/ue-create-patch-pak.webp)

Blueprint functionality also implements `uasset`, so it will also be packed in the pak rather than in the `.exe`. Blueprints run on a virtual machine (see [Blueprint FAQ and Tips](https://wiki.unrealengine.com/Blueprint_FAQ_and_Tips)), meaning blueprints are also resources, thus packed in the pak, which implies that if a project is purely implemented with blueprints, the `.exe` does not need to change, and just adding a patch can achieve game updates.

> Note: The configurations created by UnrealFrontend are stored in `Engine/Programs/UnrealFrontend/Profiles` under the `*.ulp2` files.

## UE4: Change the Language of UnrealFrontend
Edit `Engine/Programs/UnrealFrontend/Config/DefaultEngine.ini` and add the following configuration:

```ini
[Internationalization]
Culture=en
```

Changing it to `zh-CN` is Chinese, but it is not recommended to switch to Chinese, as many terms may become ambiguous.
## Creating Standalone Application with UE
You can also write applications using UE (StandaloneApplication: Target is Program), treating UE as a super large Third Party.
I wrote a template: [hxhb/UEProgramTemplate](https://github.com/hxhb/UEProgramTemplate).
Running effect:
![](https://img.imzlp.com/imgs/zlp/blog/posts/12143/UEStandaloneApplication.webp)

However, creating a new Standalone Application is quite complicated, so I wrote a small tool to create it directly: [hxhb/UECreateProgramTemplateTool](https://github.com/hxhb/UECreateProgramTemplateTool).

```bash
# Usage
$ create_program.exe $ProgramName
Create Standalone Program Successed!
  1. move $ProgramName Folder to Engine\Source\Programs (version of source code)
  2. run GenerateProgramProject.bat
  3. OpenProgramProject.bat

It is quite pleasant to use.

Note:
The configurations in *.target.cs will affect some macro definitions generated by UBT, such as:

  • bBuildWithEditorOnlyData controls WITH_EDITORONLY_DATA.
  • bCompileAgainstEngine controls WITH_ENGINE.

When developing Program type applications, you need to pay attention to these configurations. You can view all supported parameters for *.target.cs at UnrealBuildSystem/Targets.
The code in UBT parses the configurations in *.Target.cs in the Programs\UnrealBuildTools\Configuration\URBuildTarget.cs‘s SetupGlobalEnvironment function.

Registering UnrealVersionSelector

If you encounter a situation where uproject has no file association, you can use the following registry fix to associate the files.

Save as .reg and double-click to merge.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.uproject]
@="Unreal.ProjectFile"

[HKEY_CLASSES_ROOT\Unreal.ProjectFile]
@="Unreal Engine Project File"

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\DefaultIcon]
@="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell]

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\open]
@="Open"

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\open\command]
@="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\" /editor \"%1\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\run]
@="Launch game"
"Icon"="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\run\command]
@="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\" /game \"%1\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj]
@="Generate Visual Studio project files"
"Icon"="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj\command]
@="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\" /projectfiles \"%1\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\switchversion]
@="Switch Unreal Engine version..."
"Icon"="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\""

[HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\switchversion\command]
@="\"C:\\Program Files (x86)\\Epic Games\\Launcher\\Engine\\Binaries\\Win64\\UnrealVersionSelector.exe\" /switchversion \"%1\""
The article is finished. If you have any questions, please comment and communicate.

Scan the QR code on WeChat and follow me.

Title:UE工具链配置与开发技巧
Author:LIPENGZHA
Publish Date:2019/09/09 23:32
World Count:1.9k Words
Link:https://en.imzlp.com/posts/12143/
License: CC BY-NC-SA 4.0
Reprinting of the full article is prohibited.
Your donation will encourage me to keep creating!