[UE4]Project Packaging Related
keywords: UE4, Android, Packaging, Building, Deployment
Common Cases
How to include engine third party in game
Add third party name (the directory name in Engine\Source\ThirdParty\
or in Engine\Source\Runtime\
) in PublicDependencyModuleNames
in Build.cs.
e.g.
PublicDependencyModuleNames.AddRange(
new string[]
{
"HTTP",
"OpenSSL",
"libcurl",
"libWebSockets",
"Foliage"
}
);
HTTP
was in Engine\Source\Runtime\Online\HTTP
, and Foliage
was in Engine\Source\Runtime\Foliage
. If there’s a Build.cs file in somewhere, that means we can add the name of Build.cs into PublicDependencyModuleNames
.
If want to add WebSocket in your project, you can add either WebSockets
or libWebSockets
in PublicDependencyModuleNames
, because there’re two libraries of WebSocket, which are in Engine\Source\Runtime\Online\WebSockets
and Engine\Source\ThirdParty\libWebSockets
, in engine.
How to override config files (DefaultGame.ini) after Packaging?
Example of GameUserSettings.ini:
Engine\Source\Runtime\Engine\Classes\GameFramework\GameUserSettings.h
Config file directory for package:
WindowsNoEditor\MyGame\Saved\Config\WindowsNoEditor\GameUserSettings.ini
How to change save directory for shipping package
Append argument -NotInstalled
on game startup:
MyGame.exe -NotInstalled
Then “save” files will be saved in relative path ([Project]/Saved/
) of .exe, not directory C:\Users\[YourName]\AppData\Local\[YourGame]\Saved\Crashes\
.
How to disable plugin compilation in specified platform
Add WhitelistPlatforms
in .uplugin
:
"WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android", "Linux" ]
Example:
"Modules": [
{
"Name": "UnLua",
"Type": "Runtime",
"LoadingPhase": "PreDefault",
"WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android", "Linux" ]
},
{
"Name": "UnLuaEditor",
"Type": "Editor",
"LoadingPhase": "Default",
"WhitelistPlatforms": [ "Win64", "Mac" ]
}
]
Reference:
https://github.com/Tencent/UnLua/blob/master/Plugins/UnLua/UnLua.uplugin
Where is the crash dump file (Saved directory) while start game from Visual Studio
D:\MyGame\Saved\Cooked\WindowsClient\MyGame\Saved\Crashes\
Debug in Shipping
Displaying Debug information
Project Settings -> Packaging -> Project -> check Include Debug Files
.
Logging
Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs
/// <summary>
/// Whether to turn on logging for test/shipping builds.
/// </summary>
[RequiresUniqueBuildEnvironment]
public bool bUseLoggingInShipping = true;
Or modify [Project].Target.cs
:
if (Configuration == UnrealTargetConfiguration.Shipping)
{
BuildEnvironment = TargetBuildEnvironment.Unique;
bUseLoggingInShipping = true;
}
Check
Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs
/// <summary>
/// Whether to turn on checks (asserts) for test/shipping builds.
/// </summary>
[RequiresUniqueBuildEnvironment]
public bool bUseChecksInShipping = true;
Or modify [Project].Target.cs
:
if (Configuration == UnrealTargetConfiguration.Shipping)
{
BuildEnvironment = TargetBuildEnvironment.Unique;
bUseChecksInShipping= true;
}
Console Command
Engine\Source\Runtime\Core\Public\Misc\Build.h
#ifndef ALLOW_CONSOLE_IN_SHIPPING
#define ALLOW_CONSOLE_IN_SHIPPING 1
#endif
Or modify [Project].Target.cs
:
if (Configuration == UnrealTargetConfiguration.Shipping)
{
GlobalDefinitions.Add("ALLOW_CONSOLE_IN_SHIPPING=1");
}
[Available]
Some stat commands such as stat unit, stat levels, stat fps
Some dump commands such as dumpticks, dumplevelcollections, etc.
open, travel, log, r.xxx, a.xxx, t.xxx, gc.xxx, etc.
[Unavailable]
Some stat commands such as stat unitgprah, stat collision, stat startfile / stopfile
A series of commands such as showflag, obj, memreport
shot/hiresshot, toggledrawevents, profilegpu
Stats
Engine\Source\Runtime\Core\Public\Misc\Build.h
/** Compile flag to force stats to be compiled */
#ifndef FORCE_USE_STATS
#define FORCE_USE_STATS 1
#endif
Or modify [Project].Target.cs
:
if (Configuration == UnrealTargetConfiguration.Shipping)
{
GlobalDefinitions.Add("FORCE_USE_STATS=1");
}
Reference:
https://qiita.com/donbutsu17/items/76ea5c5531aa4da77f9d
UE5 Cook & Package
How to create pak file from uasset files
"D:\UE_5.3\Engine\Binaries\Win64\UnrealPak.exe" -create=E:\MyGame\Saved\Cooked\Windows -compressionformats=Zlib,Gzip,LZ4 -compress
Official command example (from .uproject):
D:\UE_5.3\Engine\Binaries\Win64\UnrealPak.exe "E:\TestTP\TestTP.uproject" -cryptokeys="E:\TestTP\Saved\Cooked\Windows\TestTP\Metadata\Crypto.json" -patchpaddingalign=2048 -compressionformats=Oodle -compresslevel=4 -compressmethod=Kraken -platform=Windows -CreateMultiple="C:\Users\Neil\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+GamesLibrary+EpicGamesStore+UE_5.3\PakCommands.txt"
Official command example (from cook directory):
D:\UE_5.3\Engine\Binaries\Win64\UnrealPak.exe -CreateGlobalContainer="E:\TestTP\Saved\StagedBuilds\Windows\TestTP\Content\Paks\global.utoc" -CookedDirectory="E:\TestTP\Saved\Cooked\Windows" -PackageStoreManifest="E:\TestTP\Saved\Cooked\Windows\TestTP\Metadata\packagestore.manifest" -Commands="C:\Users\Neil\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+GamesLibrary+EpicGamesStore+UE_5.3\IoStoreCommands.txt" -ScriptObjects="E:\TestTP\Saved\Cooked\Windows\TestTP\Metadata\scriptobjects.bin" -patchpaddingalign=2048 -compressionformats=Oodle -compresslevel=4 -compressmethod=Kraken -cryptokeys="E:\TestTP\Saved\Cooked\Windows\TestTP\Metadata\Crypto.json"
How to extract files from .pak
"D:\UE_5.3\Engine\Binaries\Win64\UnrealPak.exe" -extract E:/Test.pak E:/output
Load pak at runtime
Example Project: Loading Pak Files At Runtime
https://dev.epicgames.com/community/learning/tutorials/7Bj8/unreal-engine-example-project-loading-pak-files-at-runtime
Linux
Cross-Compiling for Linux
Cross-Compiling for Linux
https://docs.unrealengine.com/en-US/Platforms/Linux/GettingStarted/index.html
How to Cross-Compile for Linux in Unreal Engine - Setting up the Toolchain
https://www.youtube.com/watch?v=WKRi8bZCsFM
Building Unreal Engine Game Client and Dedicated Server on Linux
https://gist.github.com/zhiguangwang/42b0584ae689f0f8711790e4c05d76f1
Building and Hosting an Unreal Engine Dedicated Server with AWS and Docker
https://medium.com/swlh/building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker-75317780c567
Run UE4 on Linux
Linux Quick Start. Learn how to download, build, and run UE4 on Linux. https://docs.unrealengine.com/en-US/SharingAndReleasing/Linux/BeginnerLinuxDeveloper/SettingUpAnUnrealWorkflow/index.html
Linux Issues - Failed to load Vulkan Driver
Error on startup editor on Linux:
Failed to load Vulkan Driver which is required to run the engine. The engine no longer fallbacks to OpenGL4 which has been deprecated.
Solution:
yum install libvulkan1 mesa-vulkan-drivers vulkan-utils
Reference:
https://linuxconfig.org/install-and-test-vulkan-on-linux
Linux Issues - ThirdParty/CEF3/Linux: not in executable format: Is a directory
Error while running UE4 client on Linux:
Error while mapping shared library sections:
`/home/MyGame/LinuxNoEditor/MyGame/Binaries/Linux/../../../Engine/Binaries/ThirdParty/CEF3/Linux': not in executable format: Is a directory
Solution:
Add USE_NULL_RHI=1
in [Project].Build.cs
if(Target.Platform == UnrealTargetPlatform.Linux && Type == TargetType.Game)
{
GlobalDefinitions.Add("USE_NULL_RHI=1");
System.Console.Out.WriteLine("===================== USE_NULL_RHI=1");
}
How to generate core dump file when games crashed in shipping on Linux
Pass -core
when running applicaton on Linux:
MyProj/Binaries/MyProjServer-Linux-Shipping -core -log -port=7777
Issues
UE4 Editor modifies the value of GlobalDefinitions. This is not allowed.
Error on building:
UE4 Editor modifies the value of GlobalDefinitions. This is not allowed, as MyProjectEditor has build products in common with UE4Editor.
Solution:
Add BuildEnvironment = TargetBuildEnvironment.Unique;
into MyEditor.Target.cs
BuildEnvironment = TargetBuildEnvironment.Unique;
GlobalDefinitions.Add("AAA=1");
Origin:
https://answers.unrealengine.com/questions/920431/view.html
Chunk Downloader error: Pak cannot be unmounted with outstanding requests
Error on exiting game with ChunkDownloader enabled:
Pak cannot be unmounted with outstanding requests
Solution:
Disable pak cache on game start.
UKismetSystemLibrary::ExecuteConsoleCommand(this, TEXT("pakcache.Enable 0"));
Pak size is too large
Packaging will include all levels by default, it will cause the package to be too large.
You can specify the certain levels only needed, this will exclude unneeded assets.
岂能尽如人意,但求无愧我心。──丁聪