可可西

UE4游戏开发基础命令

在个人的Unrealengine账户中关联自己的GitHub账户成功之后,就可以访问UE4引擎的源码了。

git clone -b release https://github.com/EpicGames/UnrealEngine.git

克隆成功后,执行Setup.bat拉取并安装外部依赖文件(第三方库、资源包、示例工程等),最后调用UnrealVersionSelector添加引擎到注册表并在资源管理器中添加引擎快捷菜单功能

"%EngineDir%\Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe" /register

若需要设置代理可以传入相应参数来执行Setup.bat脚本 // Setup.bat会调用Engine\Binaries\DotNET\GitDependencies.exe工具来获取依赖文件

Setup.bat --proxy="http://10.125.224.93:8082" --force --exclude=Win32

注1:如果是UE4.22版本,需要安装.net framework 4.6.2,安装完后在控制面板卸载列表中会有如下软件列表:

注2:如果Setup出现如下错误,需要下载替换对应的Engine/Build/Commit.gitdeps.xml文件

admin@NICOCHEN-MC4 UnrealEngine % -/Setup.sh
Registering git hooks... (this will override existing ones!)
Running system mono/msbuild,version: Mono JIT compiler version 6.12.0.182 (tarbal1 Mon Jan 16 23:26:18 UTC 2023)
Checking dependencies..
Updating dependencies:% (/63488).-.
Failed to download 'http://cdn.unrealengine.com/dependencies/UnrealEngine-12372779-01515af26c634d2a8ade60b1afd1f065/01bb78539fc8dda386d45f9b5615f9a1e8ca5d94':The remote server returned an error: (403) Forbidden. (WebException)

 

https://github.com/EpicGames/UnrealEngine/releases?page=2

 

执行GenerateProjectFiles.bat生成UE4相关工程,生成的vs工程文件在Engine\Intermediate\ProjectFiles目录中

双击UE4.sln,开始编译相关工具和引擎  // 编译的中间文件生成在EngineSource\Engine\Intermediate\Build目录中

 

用来存放UE4引擎和项目代码的目录的一些注意点:

1. 目录的全路径中不要包含中文、空格

2. 目录不要放置得太深,会导致编译链接的命令行太长的错误    注:可通过在模块的Build.cs中设置bLegacyPublicIncludePaths = false来缓解

3. 目录名要以英文或下划线开头(不能以数字开头):因为UHT会利用目录名做为其符号名(注:c++中变量名、函数名不能以数字开头)的一部分

 

编译UnrealBuildTool

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "%EngineDir%\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj" /t:build /p:Configuration=Development;Platform=AnyCPU;TargetFrameworkVersion=v4.5

注1:系统自带的msbuild.exe最多支持.netframework 4.5,对于4.6及以上的版本要使用visual studio的E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe

注2:如果不想用visual studio的MSBuild.exe,需要安装

      更多信息请参看:How to build .NET 4.6 Framework app without Visual Studio installed?

 

mac下使用mono提供的xbuild工具编译UnrealBuildTool

/Users/<用户>/Engine/Binaries/ThirdParty/Mono/Mac/bin/xbuild /Users/<用户>/Engine/Source/Programs/UnrealBuildTool/UnrealBuildTool.csproj /property:Configuration="Development" /verbosity:quiet /nologo

注1:当UnrealBuildTool不存在或其源码有修改时,执行引擎目录下的GenerateProjectFiles.bat或GenerateProjectFiles.sh会重新生成UnrealBuildTool

注2:在macOS上可以使用Visual Studio for Mac来打开csproj项目进行调试(macOS没有sln解决方案文件)

 

编译引擎工具

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" ShaderCompileWorker Win64 Development -waitmutex -FromMsBuild -DEPLOY  // Windows下编译ShaderCompileWorker

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" UnrealLightmass Win64 Development -waitmutex -FromMsBuild -DEPLOY  // Windows下编译UnrealLightmass

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" UnrealIdentifierRegister Win64 Development -waitmutex -FromMsBuild -DEPLOY  // Windows下编译UnrealIdentifierRegister

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" UnrealVersionSelector Win64 Development -waitmutex -FromMsBuild -DEPLOY  // Windows下编译UnrealVersionSelector

mono $EngineDir/Engine/Binaries/DotNET/UnrealBuildTool.exe ShaderCompileWorker Mac Development  // Mac下编译ShaderCompileWorker

 

在Xcode中编译UnrealInsights,报如下错误:

Cannot code sign because the target does not have an Info.plist file and one is not being generated automatically. 
Apply an Info.plist file to the target using the INFOPLIST_FILE build setting or generate one automatically by setting the GENERATE_INFOPLIST_FILE build setting to YES (recommended).

 

使用ShaderCompilerWorker.exe编译shader

%EngineDir%/Engine/Binaries/Win64/ShaderCompileWorker.exe <AppData>/Local/Temp/UnrealShaderWorkingDir/BFE18CAA45FA658BF12AE489BE247311/5/ 27472 5 WorkerInputOnly.in WorkerOutputOnly.out -communicatethroughfile  -TimeToLive=20.000000 -Multiprocess

 

使用UnrealVersionSelector添加引擎到注册表并在资源管理器上下文菜单中添加引擎快捷功能

"%EngineDir%\Engine\Binaries\DotNET\UnrealVersionSelector.exe" /register

1. 对uproject文件进行右键菜单注册

2. 注册uproject文件所用的引擎路径

 

编译引擎和项目

编译Development版本的UE4引擎  // 会在%EngineDir%\Binaries\Win64和%EngineDir%\Plugins\*\···\*\Binaries\Win64目录中生成引擎UE4Editor.exe、核心dll模块和引擎插件dll

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" UE4Editor Win64 Development -waitmutex -FromMsBuild -DEPLOY

注1:发生重编会在开始处打印如下log,log文件在UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt目录中

TargetMakefile.Load: Makefile is older than UnrealBuildTool.exe, ignoring it
BuildMode.CreateMakefile: Creating makefile for MyGameEditor (UnrealBuildTool.exe is newer)


// --------------------------------------------------------------

Invalidating makefile for UnrealHeaderTool (Definitions.h modified)


// --------------------------------------------------------------

TargetMakefile.Load: Makefile is older than .uproject file, ignoring it
BuildMode.CreateMakefile: Creating makefile for MyGameEditor (.uproject file is newer)

注2:UBT使用ActionGraph分析模块的代码是否需要Outdated,然后执行lib、pdb的清理工作

ActionGraph.IsActionOutdated: PCH.Core.cpp: Dependency GenericPlatformMisc.h is newer than the last execution of the action: 2023/2/2 21:26:10 vs 2023/1/31 9:47:55
ActionGraph.IsActionOutdated: SharedPCH.Slate.ShadowErrors.cpp: Dependency GenericPlatformMisc.h is newer than the last execution of the action: 2023/2/2 21:26:10 vs 2023/1/31 9:48:11
ActionGraph.IsActionOutdated: UE4Editor-Core.lib: Prerequisite PCH.Core.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: Module.TraceDataFiltering.cpp: Prerequisite SharedPCH.Slate.ShadowErrors.cpp is produced by outdated action.
。。。 。。。
ActionGraph.IsActionOutdated: UE4Editor-NetworkFile.dll: Prerequisite SharedPCH.CoreUObject.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-PlayTimeLimit.dll: Prerequisite SharedPCH.CoreUObject.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-ReliabilityHandlerComponent.dll: Prerequisite SharedPCH.Core.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: Module.PlayTimeLimit.cpp: Prerequisite SharedPCH.CoreUObject.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-TakeRecorderSources.lib: Prerequisite SharedPCH.UnrealEd.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-GeometryCacheAbcFile.lib: Prerequisite SharedPCH.UnrealEd.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-DataValidation.lib: Prerequisite SharedPCH.UnrealEd.ShadowErrors.cpp is produced by outdated action.
ActionGraph.IsActionOutdated: UE4Editor-Gauntlet.lib: Prerequisite SharedPCH.Engine.ShadowErrors.cpp is produced by outdated action.
ActionGraph.DeleteOutdatedProducedItems: Deleting outdated item: D:\svn\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\Core\UE4Editor
-Core.lib ActionGraph.DeleteOutdatedProducedItems: Deleting outdated item: D:\svn\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\CoreUObject\UE4Editor-CoreUObject.lib 。。。 。。。 ActionGraph.DeleteOutdatedProducedItems: Deleting outdated item: D:\svn\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Engine.pdb ActionGraph.DeleteOutdatedProducedItems: Deleting outdated item: D:\svn\UnrealEngine\Engine\Binaries\Win64\UE4Editor-UnrealEd.pdb

注3:对比UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\DebugGame\UnrealHeaderTool中的Definitions.hDefinitions.h.old文件来决定是否需要重编译

 

生成了UE4.sln或UE4.xcworkspace,也可以使用msbuild.exe或xcodebuild来编译  

// vs2017的msbuild所在目录:Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
msbuild.exe UE4.sln /p:Configuration="Development Editor" /p:Platform=Win64 /m:8  // 使用并发线程数为8,编译配置为:Development Editor Win64来编译生成UE4Editor.exe

xcodebuild -workspace UE4.xcworkspace/ -scheme UE4 -configuration "Development Editor" // xcode下编译Development Editor的UE4Editor

xcode编译出的UE4Editor所在目录:%EngineDir%/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor

 

生成项目MyGame的项目工程文件  // 工程文件会生成到"%GameDir%\Intermediate\ProjectFiles"目录中 

"%EngineDir%\Engine\Binaries\Win64\UnrealVersionSelector.exe" /projectfiles "%GameDir%\MyGame.uproject"   //windows下

"%EngineDir%/Engine/Binaries/DotNET/UnrealBuildTool.exe"  -projectfiles -project="%GameDir%\MyGame.uproject" -game -engine -progress -log="%GameDir%/Saved/Logs/UnrealVersionSelector-2020.12.31-11.34.19.log"  //windows下

"%EngineDir%/Engine/Binaries/DotNET/UnrealBuildTool.exe"  -projectfiles -project="%GameDir%\MyGame.uproject" -game -engine -VSCode   //windows下生成vscode项目工程

"%EngineDir%/Engine/Binaries/DotNET/UnrealBuildTool.exe"  -projectfiles -project="%GameDir%\MyGame.uproject" -game -engine -2019  //windows下生成vs2019项目工程  注:vs2019使用的c++14

"%EngineDir%/GenerateProjectFiles.sh" -project="%GameDir%/MyGame.uproject" -Game -Engine // Mac或Linux下

"%EngineDir%/GenerateProjectFiles.sh" -project="%GameDir%/MyGame.uproject" -platforms=IOS -game -nointellisense -IOSdeployonly -ignorejunk -projectfileformat=XCode -includetemptargets  // Mac下专有IOS工程

 

注:windows下,可在UE4编辑器菜单File -- Refresh Visual Studio Project来生成或刷新vs项目文件;在Mac下,可在UE4编辑器菜单File -- Refresh XCode Project来生成或刷新xCode项目文件      【与上面命令是等价的】

 

编译项目MyGame的Development Editor版本  // 会在%GameDir%\Binaries\Win64和%GameDir%\Plugins\*\···\*\Binaries\Win64目录中生成项目dll和项目插件dll

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" MyGameEditor Win64 Development "%GameDir%\MyGame.uproject" -waitmutex -FromMsBuild -DEPLOY // windows下

$EngineDir/Engine/Build/BatchFiles/Mac/XcodeBuild.sh MyGameEditor macosx Development %GameDir%/MyGame.uproject // Mac下

mono $EngineDir/Engine/Binaries/DotNET/UnrealBuildTool.exe  MyGameEditor macosx Development %GameDir%/MyGame.uproject // Mac下

编译日志UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt中会输出uplugin的依赖关系:

// 日志开头处,会打印插件是怎么被Enable开启的引用关系链
UEBuildTarget.AddPlugin: Enabling plugin 'GeometryProcessing' (referenced via MyGame.uproject -> MeshPainting.uplugin) // GeometryProcessing插件被开启:因为UAGame.uproject依赖MeshPainting插件,MeshPainting插件又依赖GeometryProcessing插件
UEBuildTarget.AddPlugin: Enabling plugin 'AndroidDeviceProfileSelector' (referenced via MyGame.uproject)  // AndroidDeviceProfileSelector插件被开启:因为UAGame.uproject依赖AndroidDeviceProfileSelector插件

 

编译项目MyGame的Development Android版本(libUE4.so) 

UnrealBuildTool.exe  MyGame Android Development -Project=%GameDir%\MyGame.uproject"

 

编译项目MyGame的Client Development Android版本(libUE4.so) 

UnrealBuildTool.exe  MyGameClient Android Development -Project=%GameDir%\MyGame.uproject" -Architectures=arm64

 

编译项目MyGame的Debug IOS版本(MyGame可执行二进制) 

mono $EngineDir$/Engine/Binaries/DotNET/UnrealBuildTool.exe MyGame IOS Debug -Project=$GameDir$/MyGame.uproject
$EngineDir$/Engine/Build/BatchFiles/Mac/Build.sh -Target="MyGame IOS Debug" -Project=$GameDir$/MyGame.uproject

 

编译单个c/cpp文件

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe"  MyGameEditor Win64 Development "%GameDir%\MyGame.uproject" -singlefile="%GameDir%\Source\MyGame\MyGameCharacter.cpp" -WaitMutex -FromMsBuild -DEPLOY

编译单个模块

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" -Module=MyGame Win64 Development -TargetType=Editor -Project="%GameDir%\MyGame.uproject" -canskiplink "%GameDir%\MyGame.uproject"

编译单个引擎模块

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" -Module=Engine Win64 Development -TargetType=Editor -Project="%GameDir%\MyGame.uproject" -canskiplink -nosharedpch "%GameDir%\MyGame.uproject"

编译多个模块 

"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" -Module=MyCommon -Module=MyGame Win64 Development -TargetType=Editor -Project="%GameDir%\MyGame.uproject" -canskiplink "%GameDir%\MyGame.uproject" 

注1:更多额外命令行参数见UnrealBuildTool中的GlobalOptions类中的CommandLine修饰的成员变量

-Verbose、-VeryVerbose、-Log、-Timestamps、-Progress、-NoMutex、-RemoteIni、-SkipDeploy、-Clean、

-ProjectFiles、-ProjectFileFormat=、-2017、-2019、-2022、-Makefile、-CMakefile、-QMakefile、-KDevelopfile、-CodeliteFiles、-XCodeProjectFiles、-EdditProjectFiles、-VSCode、-VSMac、-CLion、-Rider

注2:更多额外命令行参数见UnrealBuildTool中的TargetDescriptor类中的CommandLine修饰的成员变量

-NoHotReload、-ForceHotReload、-LiveCoding、-WriteActions=c:\myAction.txt (输出编译链接过程中详细信息)

-mode=JsonExport(读取所有build.cs,输出modules的依赖关系)、-LiveCodingModules=modulelist.txt、-LiveCodingManifest=mymenifest.txt、-Quiet

// 编译链接出so文件,另外记录编译链接各命令行的日志文件会输出在c:\svn\myAction.txt
C:\svn\UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool.exe  UAGame Android Shipping -Project="C:\svn\R6Game\UAGame.uproject" -WriteActions="c:\svn\myAction.txt"

// 不会编译链接出so文件,json文件会输出在C:\svn\R6Game\Binaries\Android\UAGame-Android-Shipping.json
C:\svn\UnrealEngine\Engine\Binaries\DotNET\UnrealBuildTool.exe  UAGame Android Shipping -Project="C:\svn\R6Game\UAGame.uproject" -mode=JsonExport

 

编译项目MyGame的客户端版本

"%EngineDir%\Engine\Binaries\Win64\UnrealVersionSelector.exe" MyGame Win64 Development -Project="%GameDir%\MyGame.uproject"

编译项目MyGame的Linux Server版本

mono "%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" MyGameServer Linux Development -Project="%GameDir%\MyGame.uproject"

构建安装版引擎

%EngineDir%\Engine\Build\BatchFiles\RunUAT.bat BuildGraph -target="Make Installed Build Win64" -script=Engine/Build/InstalledEngineBuild.xml -set:WithMac=false -set:WithAndroid=false -set:WithIOS=false -set:WithTVOS=false -set:WithLinux=false -set:WithHTML5=false -set:WithSwitch=false -WithDDC=false -set:WithWin32=false -set:WithLumin=false -set:WithPS4=false -set:WithXboxOne=false -set:WithHoloLens=false -set:GameConfigurations=Development

配置文件详见 :Engine/Build/InstalledEngineBuild.xml

构建好的安装版引擎在:%EngineDir%\LocalBuilds\Engine\Windows目录中

注1:可放置一个%EngineDir%/Engine/Build/InstalledBuild.txt空文件,将当前引擎标识成一个InstalledEngine

注2:InstalledEngine主要用来提升团队开发效率,让构建机生产好这些二进制内容,而不需要每个人都来编译一遍。

        ① 引擎编辑器(UE4Editor.exe)、构建工具链(UBT、UHT、UAT)以及第三方工具(UnrealPak.exe、ShaderCompileWorker.exe、UnrealLightmass.exe等)

           (a)引擎编辑器、第三方工具和UHT     在%EngineDir%/Engine/Binaries/Win64目录中

           (b)UBT、UAT     在%EngineDir%/Engine/Binaries/DotNET目录中

        ② 引擎及项目依赖的所有模块的.h、.generated.h、.lib、.dll文件

           (a).h     在%EngineDir%/Engine/Source、%EngineDir%/Engine/Plugins/<xxx>/Source目录中

           (b).generated.h、.lib     在%EngineDir%/Engine/Intermediate、%EngineDir%/Engine/Plugins/<xxx>/Intermediate目录中

           (c).dll     在%EngineDir%/Engine/Binaries/Win64、%EngineDir%/Engine/Plugins/<xxx>/Binaries/Win64目录中

注3:cpp代码不是必须的

 

UnrealPak

解压未加密的MyGame-Android_ASTC.pak包到%Output%/MyGame-Android_ASTC目录中

%EngineDir%/Engine/Binaries/Win64/UnrealPak.exe "%MyGame-arm64-es2%/assets/MyGame/Content/Paks/MyGame-Android_ASTC.pak" -Extract "%Output%/MyGame-Android_ASTC"

 

有Crypto.json秘钥文件时,解压加密的MyGame-Android_ASTC.pak包到%Output%/MyGame-Android_ASTC目录中

%EngineDir%/Engine/Binaries/Win64/UnrealPak.exe "%MyGame-arm64-es2%/assets/MyGame/Content/Paks/MyGame-Android_ASTC.pak" -Extract "%Output%/MyGame-Android_ASTC" -cryptokeys="%GameDir%/Saved/Cooked/Android_ASTC/MyGame/Metadata/Crypto.json"

 

无Crypto.json秘钥文件时,解压加密的MyGame-Android_ASTC.pak包到%Output%/MyGame-Android_ASTC目录中

%EngineDir%/Engine/Binaries/Win64/UnrealPak.exe "%MyGame-arm64-es2%/assets/MyGame/Content/Paks/MyGame-Android_ASTC.pak" -Extract "%Output%/MyGame-Android_ASTC" -ExtractToMountPoint -encryptindex -encryptionini -projectdir="%GameDir%" -enginedir="%EngineDir%" -Platform=Windows

注1:该方式会通过读取%GameDir%/Config/DefaultCrypto.ini中的秘钥来解密

注2:需要在项目的%GameDir%/Config/DefaultEngine.ini中进行如下配置,来将项目标识为一个加密类型

 

注3:增加-ExtractToMountPoint参数会保留到根上的所有目录结构

 

windows打包pak

"%EngineDir%\Engine\Binaries\Win64\UnrealPak.exe" %GameDir%\UAGame.uproject %GameDir%\Saved\StagedBuilds\WindowsNoEditor\UAGame\Content\Paks\pakchunk0-WindowsNoEditor.pak -create=%EngineDir%\Engine\Programs\AutomationTool\Saved\Logs\PakList_pakchunk0-WindowsNoEditor.txt -cryptokeys=%GameDir%\Saved\Cooked\WindowsNoEditor\UAGame\Metadata\Crypto.json -order=%GameDir%\Build\WindowsNoEditor\FileOpenOrder\CookerOpenOrder.log -encryptindex -sign -patchpaddingalign=2048 -platform=Windows  -multiprocess -abslog=%EngineDir%\Engine\Programs\AutomationTool\Saved\Logs\UnrealPak-pakchunk0-WindowsNoEditor-2022.02.15-16.33.18.txt 

Android打包pak

"%EngineDir%\Engine\Binaries\Win64\UnrealPak.exe" %GameDir%\UAGame.uproject %GameDir%\Saved\StagedBuilds\Android_ASTC\UAGame\Content\Paks\pakchunk1-Android_ASTC.pak -create=%EngineDir%\Eng
ine\Programs\AutomationTool\Saved\Logs\PakList_pakchunk1-Android_ASTC.txt -cryptokeys=%GameDir%\Saved\Cooked\Android_ASTC\UAGame\Metadata\Crypto.json -order=%GameDir%\Build\Android_ASTC\FileOpenOrder\CookerOpenOrder.log -encryptindex -platform=Android  -multiprocess -abslog=%EngineDir%\Engine\Programs\AutomationTool\Saved\Logs\U
nrealPak-pakchunk1-Android_ASTC-2022.02.15-13.05.20.txt

IOS打包pak

"$EngineDir$/Engine/Binaries/Win64/UnrealPak.exe" $GameDir$/UAGame.uproject $GameDir$/Saved/StagedBuilds/IOS/cookeddata/uagame/content/paks/pakchunk1-ios.pak -create="/Users/admin/L
ibrary/Logs/Unreal Engine/LocalBuildLogs/PakList_pakchunk1-ios.txt" -cryptokeys=$GameDir$/Saved/Cooked/IOS/UAGame/Metadata/Crypto.json -order=/Users/admin/UAGroup
/R6Game/Build/IOS/FileOpenOrder/CookerOpenOrder.log -encryptindex -platform=IOS -AlignForMemoryMapping=16384  -multiprocess -abslog="/Users/admin/Library/Logs/Unreal Engine/LocalBu
ildLogs/UnrealPak-pakchunk1-ios-2022.02.15-13.03.40.txt"

 

UnrealPak的log所在目录:%EngineDir%\Engine\Programs\UnrealPak\Saved\Logs\UnrealPak.log

 

UHT扫描头文件命令行

// UHT扫描UE4工程
"%EngineDir%\Engine\Binaries\Win64\UnrealHeaderTool.exe" UE4Editor "%EngineDir%\Engine\Intermediate\Build\Win64\UE4Editor\DebugGame\UE4Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="%EngineDir%\Engine\Programs\UnrealBuildTool\Log_UHT.txt" 

// UHT扫描MyGame项目工程
"%EngineDir%\Engine\Binaries\Win64\UnrealHeaderTool.exe" "%GameDir%\MyGame.uproject" "%GameDir%\Intermediate\Build\Win64\MyGameEditor\DebugGame\MyGameEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="%EngineDir%\Engine\Programs\UnrealBuildTool\Log_UHT.txt"

// UHT扫描ShaderCompileWorker工程
"%EngineDir%\Engine\Binaries\Win64\UnrealHeaderTool.exe" ShaderCompileWorker "%EngineDir%\Engine\Intermediate\Build\Win64\ShaderCompileWorker\Development\ShaderCompileWorker.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="%EngineDir%\Engine\Programs\UnrealBuildTool\Log_UHT.txt"

 

一些log

UnrealHeaderTool:UnrealEngine\Engine\Programs\UnrealHeaderTool\Saved\Logs\UnrealHeaderTool.log

UnrealBuildTool:UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt

            AppData\Local\UnrealBuildTool\Log.txt(InstalledEngine)

UAT:UnrealEngine\Engine\Programs\AutomationTool\Saved\Logs\Log.txt

          UnrealEngine\Engine\Programs\AutomationTool\Saved\Logs\Cook-2020.07.13-17.32.30.txt

MyGame:MyGame\Saved\Logs\MyGame.log

 

Mac osx上的log

UnrealHeaderTool:~\Library\Logs/Unreal Engine/UnrealHeaderTool/UnrealHeaderTool.log

UnrealBuildTool:UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt

UAT:~\Library\Logs/Unreal Engine/LocalBuildLogs中,包含一下一些文件

Cook-2020.07.13-17.46.05.txt   // Cook资源的log
FinalCopy_NonUFSFiles.txt
FinalCopy_NonUFSFilesDebug.txt
FinalCopy_UFSFiles.txt
Log.txt    // 编译ios版本的log
Manifest_NonUFSFiles_IOS.txt
PakList_basicasset-ios.txt
PakList_uagame-ios.txt
PrePak_IOS_NonUFSFiles.txt
PrePak_IOS_NonUFSFilesDebug.txt
PrePak_IOS_UFSFiles.txt
UBT-UAGame-IOS-Development.txt
UBT-UnrealPak-Mac-Development.txt
UnrealPak-basicasset-ios-2020.07.13-17.47.12.txt
UnrealPak-uagame-ios-2020.07.13-17.47.12.txt

 

MyGame:~\Library\Logs/Unreal Engine/MyGameEditor/MyGame.log

 

一些技巧

(1)不要把DDC(Derived Data Cache)目录设置到机械硬盘上,要放在SSD上,否则使用编辑器时会很卡(如:移动场景中的物体)   注:其缺省会在<User Folder>/AppData/Local/UnrealEngine中

(2)去掉UE4和游戏工程的所有Depends(工程右键菜单 -- Build Dependencies -- Project Dependencies ...),手动编译各个工程,防止修改一个工程后,引发依赖该工程发生重编译

(3)去掉UE4和游戏工程NMake命令行上的对ShaderCompileWorker的依赖

可在引擎工程:Engine/Saved/UnrealBuildTool/BuildConfiguration.xml中关闭Generate Visual Studio Project files时对ShaderCompileWorker的依赖

<?xml version="1.0" encoding="utf-8" ?>
 <Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
     <BuildConfiguration>
         <bEditorDependsOnShaderCompileWorker>false</bEditorDependsOnShaderCompileWorker>
     </BuildConfiguration>
 </Configuration>

(4)关闭每次构建项目都自动构建UnrealHeaderTool 

在Engine/Saved/UnrealBuildTool/BuildConfiguration.xml中增加如下配置:

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
     <UEBuildConfiguration>
         <bDoNotBuildUHT>true</bDoNotBuildUHT>
     </UEBuildConfiguration>
</Configuration>

注1:从UnrealHeaderTool.Build.cs中可知:UHT依赖6个基础的引擎模块:CoreCoreUObjectJsonProjectsTraceLog(Core、CoreUObject依赖TraceLog,所以UHT也间接依赖它)和BuildSettings(Core依赖BuildSettings,所以UHT也间接依赖它)

注2:开启UHT的DoNotBuild模式,会导致Unlua中Program类型的模块UnLuaDefaultParamCollectorUnLuaIntelliSense编译不出来。

         可将它们编译出来后,再开启UHT的DoNotBuild模式

 

(5)Tools - Options - Projects and Solutions,取消勾选Always show Error List if build finishes with errors,防止每次编译有错,vs都自动激活显示Error List面板

(6)关闭Visual Studio自带git插件,避免每次编译都要进行git status的检查,提升开发效率

1>------ Build started: Project: MyTest1, Configuration: Debug_Editor x64 ------
1>Using 'git status' to determine working set for adaptive non-unity build (G:\svn\UnrealEngine).
1>Using 'git status' to determine working set for adaptive non-unity build (G:\svn\MyTest1).
1>Waiting for 'git status' command to complete

 

(7)将Solution Configurations的宽度调成为150,让其能显示完全

         菜单项:Tools - Options - Customize

(8)编译时不要用满所有cpu的核,否则计算机会非常卡,基本无法进行其他工作

   在BuildConfiguration.xml中进行配置,将MaxProcessorCount设置成7(我本机是8核cpu)

<?xml version="1.0" encoding="utf-8" ?>
 <Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
     <ParallelExecutor>
         <MaxProcessorCount>7</MaxProcessorCount>
     </ParallelExecutor>
     <BuildConfiguration>
         <bAllowXGE>true</bAllowXGE>
     </BuildConfiguration>
 </Configuration>

 注:bAllowXGE表示是否开启IncrediBuild(XGE)

BuildConfiguration.xml会按照下面路径的顺序来进行查找来加载   更多信息详见:Build Configuration

  ① 引擎工程:Engine/Saved/UnrealBuildTool/BuildConfiguration.xml
  ② <User Folder>/AppData/Roaming/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml
  ③ <My Documents>/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml

修改了BuildConfiguration.xml,编译时会提示如下log,并重编译整个项目:

Using 'git status' to determine working set for adaptive non-unity build (H:\svn\UnrealEngine).
Creating makefile for UAGame (BuildConfiguration.xml is newer)
。。。 。。。

 

扩展:BuildConfiguration.xml相关的参数可见生成出来的BuildConfiguration.Schema.xsd

其内容如下:

<?xml version="1.0" encoding="utf-8"?>
<schema elementFormDefault="qualified" targetNamespace="https://www.unrealengine.com/BuildConfiguration" xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="Configuration">
        <complexType>
            <all>
                <element minOccurs="0" maxOccurs="1" name="BuildConfiguration">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bGeneratedSYMFile" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableAddressSanitizer" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableThreadSanitizer" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableUndefinedBehaviorSanitizer" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="BaseLogFileName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowDistccLocalFallback" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bVerboseDistccOutput" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="DistccExecutablesPath" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="DMUCSCoordinator" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="DMUCSDistProp" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bXGENoWatchdogThread" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bShowXGEMonitor" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bStopXGECompilationAfterErrors" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bWriteSolutionOptionFile" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAddFastPDBToProjects" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePerFileIntellisense" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bEditorDependsOnShaderCompileWorker" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bDebugBuildsActuallyUseDebugCRT" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseInlining" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseDebugLiveCodingConsole" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseXGEController" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseUnityBuild" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bForceUnityBuild" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseAdaptiveUnityBuild" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAdaptiveUnityDisablesOptimizations" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAdaptiveUnityDisablesPCH" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAdaptiveUnityDisablesProjectPCHForProjectPrivate" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAdaptiveUnityCreatesDedicatedPCH" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAdaptiveUnityEnablesEditAndContinue" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MinGameModuleSourceFilesForUnityBuild" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="UnsafeTypeCastWarningLevel">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="Off" />
                                        <enumeration value="Warning" />
                                        <enumeration value="Error" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="bUndefinedIdentifierErrors" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseFastMonoCalls" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseFastSemanticsRenderContexts" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="NumIncludedBytesPerUnityCPP" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="bStressTestUnity" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bDisableDebugInfo" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bDisableDebugInfoForGeneratedCode" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bOmitPCDebugInfoInDevelopment" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePDBFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePCHFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MinFilesUsingPrecompiledHeader" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="bForcePrecompiledHeaderForGameModules" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseIncrementalLinking" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowLTCG" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowThinLTO" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bOptimizeReflectionSys" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bPGOProfile" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bPGOOptimize" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bSupportEditAndContinue" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bOmitFramePointers" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseMallocProfiler" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseLoliProfiler" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseSharedPCHs" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseShippingPhysXLibraries" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseCheckedPhysXLibraries" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bCheckLicenseViolations" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bBreakBuildOnLicenseViolation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseFastPDBLinking" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bCreateMapFile" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowRuntimeSymbolFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bCheckSystemHeadersForModification" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bFlushBuildDirOnRemoteMac" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bPrintToolChainTimingInfo" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bParseTimingInfoForTracing" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bPublicSymbolsByDefault" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="CppStandard">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="Default" />
                                        <enumeration value="Cpp14" />
                                        <enumeration value="Cpp17" />
                                        <enumeration value="Latest" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="bStripSymbols" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableMemorySanitizer" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIgnoreOutdatedImportLibraries" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bPrintDebugInfo" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bLogDetailedActionStats" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowHybridExecutor" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowXGE" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowFASTBuild" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowSNDBS" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUseUBTMakefiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowDistcc" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowParallelExecutor" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MaxParallelActions" type="int" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="HybridExecutor">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="MaxLocalActions" type="int" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="BuildMode">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIgnoreJunk" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="ProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="DisablePlatformProjectGenerators">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="Format" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bGenerateIntelliSenseData" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllDocumentationLanguages" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeBuildSystemFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeLocalizationFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTempTargets" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDotNETCoreProjects" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bKeepSourceSubDirectories" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="Platforms">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="Configurations">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTestAndShippingConfigs" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="LocalExecutor">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="ProcessorCountMultiplier" type="double" />
                            <element minOccurs="0" maxOccurs="1" name="MaxProcessorCount" type="int" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="ParallelExecutor">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="MaxProcessorCount" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="ProcessorCountMultiplier" type="double" />
                            <element minOccurs="0" maxOccurs="1" name="bStopCompilationAfterErrors" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="XGE">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bAllowOverVpn" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="VpnSubnets">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="FASTBuild">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="FBuildExecutablePath" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableDistribution" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="FBuildBrokeragePath" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bEnableCaching" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="CacheMode">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="ReadWrite" />
                                        <enumeration value="ReadOnly" />
                                        <enumeration value="WriteOnly" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="FBuildCachePath" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bForceRemote" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bStopOnError" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MsvcCRTRedistVersion" type="string" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="CLionGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="CMakefileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="CodeLiteGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="EddieProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="KDevelopGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="MakefileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="QMakefileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="RiderProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="VSCodeProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="IncludeAllFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="VCProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="Version">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="Default" />
                                        <enumeration value="VisualStudio2012" />
                                        <enumeration value="VisualStudio2013" />
                                        <enumeration value="VisualStudio2015" />
                                        <enumeration value="VisualStudio2017" />
                                        <enumeration value="VisualStudio2019" />
                                        <enumeration value="VisualStudio2022" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="MaxSharedIncludePaths" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="ExcludedIncludePaths" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bBuildUBTInDebug" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bBuildLiveCodingConsole" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="XcodeProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="ModuleConfiguration">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="DisableUnityBuild">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="EnableOptimizeCode">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="DisableOptimizeCode">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="EnableOptimizeSizeForModules">
                                <complexType>
                                    <sequence>
                                        <element minOccurs="0" maxOccurs="unbounded" name="Item" type="string" />
                                    </sequence>
                                </complexType>
                            </element>
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="SourceFileWorkingSet">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="Provider">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="None" />
                                        <enumeration value="Default" />
                                        <enumeration value="Perforce" />
                                        <enumeration value="Git" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="RepositoryPath" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="GitPath" type="string" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="VCMacProjectFileGenerator">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bIncludeDocumentation" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bUsePrecompiled" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEngineSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeEnterpriseSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeShaderSource" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeConfigFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bIncludeTemplateFiles" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="IncludeEnginePrograms" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="MasterProjectName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bMasterProjectNameFromFolder" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="IOSToolChain">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="IOSSDKVersion" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="BuildIOSVersion" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="bUseDangerouslyFastMode" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="RemoteMac">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="ServerName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="UserName" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="SshPrivateKey" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="RsyncAuthentication" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="SshAuthentication" type="string" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="HoloLensPlatform">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="Compiler">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="Default" />
                                        <enumeration value="Clang" />
                                        <enumeration value="Intel" />
                                        <enumeration value="VisualStudio2015_DEPRECATED" />
                                        <enumeration value="VisualStudio2015" />
                                        <enumeration value="VisualStudio2017" />
                                        <enumeration value="VisualStudio2019" />
                                        <enumeration value="VisualStudio2022" />
                                    </restriction>
                                </simpleType>
                            </element>
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="UEBuildConfiguration">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="bForceHeaderGeneration" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bDoNotBuildUHT" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bFailIfGeneratedCodeChanges" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bAllowHotReloadFromIDE" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bForceDebugUnrealHeaderTool" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="WindowsPlatform">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="MaxRootPathLength" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="MaxNestedPathLength" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="Compiler">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="Default" />
                                        <enumeration value="Clang" />
                                        <enumeration value="Intel" />
                                        <enumeration value="VisualStudio2015_DEPRECATED" />
                                        <enumeration value="VisualStudio2015" />
                                        <enumeration value="VisualStudio2017" />
                                        <enumeration value="VisualStudio2019" />
                                        <enumeration value="VisualStudio2022" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="CompilerVersion" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="WindowsSdkVersion" type="string" />
                            <element minOccurs="0" maxOccurs="1" name="StaticAnalyzer">
                                <simpleType>
                                    <restriction base="string">
                                        <enumeration value="None" />
                                        <enumeration value="VisualCpp" />
                                        <enumeration value="PVSStudio" />
                                    </restriction>
                                </simpleType>
                            </element>
                            <element minOccurs="0" maxOccurs="1" name="bStrictConformanceMode" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="PCHMemoryAllocationFactor" type="int" />
                            <element minOccurs="0" maxOccurs="1" name="bClangTimeTrace" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bCompilerTrace" type="boolean" />
                            <element minOccurs="0" maxOccurs="1" name="bShowIncludes" type="boolean" />
                        </all>
                    </complexType>
                </element>
                <element minOccurs="0" maxOccurs="1" name="WindowsTargetRules">
                    <complexType>
                        <all>
                            <element minOccurs="0" maxOccurs="1" name="ObjSrcMapFile" type="string" />
                        </all>
                    </complexType>
                </element>
            </all>
        </complexType>
    </element>
</schema>

 

还有一种快速禁掉IncrediBuild方法是将c:\Programe Files(x86)\IncrediBuild\xgConsole.exe改名

注:对于IncrediBuild的lincese,本机参与编译的核数<=购买的核数,  共享出去的cpu核算可以自己设置, 也不能超过购买的核数

(9)如果只是想禁用shader编译的IncrediBuild的加速,可在Engine\Config\ConsoleVariables.ini中打开r.XGEShaderCompile = 0

(10)从vs直接运行或调试运行UE时,不要进行任何编译行为

(11)UnrealVS扩展中文

右键Visual Studio工具栏区域,弹出快捷菜单,勾选显示UnrealVS工具栏

安装文件在:Engine\Extras\UnrealVS

代码在:Engine\Source\Programs\UnrealVS

提供了如下功能:

a. 设置启动项目
b. 绑定构建启动项目的命令
c. 设置命令行参数
d. 批量构建项目
f. 快速构建项目菜单

(12)出现断点打不上(空心带黄色感叹号)的情况(如:调试Release版本、可执行程序目录发生过变化等),需要做一下检查和设置

① vs处于调试态时,在菜单Debug -- Windows -- Modules面板里,搜索目标模块的pdb是否加载

② vs设置:Tools - Options - Debugging  -  取消勾选“Require source files to exactly match the original version”

(13)改善C++调试:在vs进行C++调试时更好地查看Unreal自定义类型变量(如:FName,FString,TArray等)

运行Engine\Extras\VisualStudioDebugging\InstallVisualizers.bat(支持vs2012、vs2013、vs2015)进行安装

对于vs2017等更高版本,可以手动将Engine\Extras\VisualStudioDebugging\UE4.natvis拷贝到%USERPROFILE%\Documents\Visual Studio 2017\Visualizers目录中进行手动安装

安装完成后,重启vs

vs设置:Tools - Options - Debugging  -  取消勾选“Show raw structure of objects in variables windows”

(14)开启vs的Intellisense(智能感知)功能

在编写代码实时键入时,IntelliSense将重新编译C++,进行实时错误和筛选。此功能比VAX的语法检查更加强大,其使用的是完整C++编译器,可逐行验证代码,可极大加快工作流

注1:左下角的图标表示图标IntelliSense编译程序正在运行

注2:vs默认是开启Intellisense的,如果没有启用,请检查以下设置项

(15)配置并使用ue4的Snippet自动完成,来插入模板代码

配置方法:拷贝Engine\Extras\VisualStudioSnippets中所有的snippet文件到C:\Users\<user>\Documents\Visual Studio 2017\Code Snippets\Visual C++\My Code Snippets目录中,并重启vs

然后在UE4的项目中输入:ue4  就会出现snippet列表,选择某项snippet后就会插入对应模板代码

扩展:ue4snippets github    Snippet各个文件说明

(16)禁用“编译出错时始终显示错误列表”(Always show Error List if build finishes with error)  注:防止编译失败后自动弹出错误列表

(17)Disable显示非活动代码块   注:关闭该选项后,代码会正常显示(#if 为false的代码块会变灰)

 

 

更多请参考:设置虚幻引擎的Visual Studio中文

 

运行引擎和项目

启动引擎编辑器

"%EngineDir%/Engine/Binaries/Win64/UE4Editor.exe" -skipcompile

启动项目编辑器

"%EngineDir%/Engine/Binaries/Win64/UE4Editor.exe"  "%GameDir%\MyGame.uproject" -skipcompile

单机启动游戏单机

"%EngineDir%/Engine/Binaries/Win64/UE4Editor.exe"  "%GameDir%\MyGame.uproject" TestMap_Main -game -skipcompile

"%EngineDir%\Engine\Binaries\Win64\UE4Editor.exe"  "%GameDir%/MyGame.uproject" /Game/TestMap -game -PIEVIACONSOLE  -Multiprocess  GameUserSettingsINI="%GameDir%/Saved/Config/Windows/PIEGameUserSettings0.ini" -MultiprocessSaveConfig -MultiprocessOSS -messaging -SessionName="Play in Standalone Game" -windowed -WinX=309 -WinY=152 SAVEWINPOS=1 -ResX=1280 -ResY=720

启动本地ds

"%EngineDir%/Engine/Binaries/Win64/UE4Editor.exe"  "%GameDir%\MyGame.uproject" TestMap_Main -game -server -log -skipcompile

启动游戏并联网加入本地ds

"%EngineDir%/Engine/Binaries/Win64/UE4Editor.exe"  "%GameDir%\MyGame.uproject" 127.0.0.1 -game -skipcompile

 

版本打包

① win64 -- Development版本包  会输出到%Win64Dir%\WindowsNoEditor目录中

%EngineDir%\Engine\Build\BatchFiles\RunUAT.bat -ScriptsForProject=%GameDir%\MyGame.uproject BuildCookRun -project=%GameDir%\MyGame.uproject -targetplatform=Win64 -clientconfig=Development -ue4exe=UE4Editor-Cmd.exe -noP4 -iterate -cook -pak -package -stage -archive -archivedirectory=%Win64Dir% -nocompileeditor -prereqs -nodebuginfo -build -CrashReporter -utf8output -compressed

打包后的目录结构如下:

 

启动器exe将自身的命令行参数(UAGame -FeatureLevelES31)传给并拉起游戏exe

 

启动器exepdb符号表所在目录:D:\svn\UnrealEngine\Engine\Binaries\Win64\BootstrapPackagedGame-Win64-Shipping.pdb

                    main函数所在代码文件:D:\svn\UnrealEngine\Engine\Source\Programs\Windows\BootstrapPackagedGame\Private\BootstrapPackagedGame.cpp

 

游戏exepdb符号表所在目录:D:\svn\R6Game\Binaries\Win64\UAGame-Win64-Test.pdb

                main函数所在代码文件:D:\svn\UnrealEngine\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp

 

② Android -- Debug版本包  会输出到%ApkDir%\Android_ETC2目录中    windows下安装Android构建环境 (en

%EngineDir%\Engine\Build\BatchFiles\RunUAT.bat -ScriptsForProject=%GameDir%\MyGame.uproject BuildCookRun -nocompileeditor -nop4 -iterate -project=%GameDir%\MyGame.uproject -cook -stage -archive -archivedirectory=%ApkDir% -package -clientconfig=Debug -ue4exe=UE4Editor-Cmd.exe -compressed -pak -prereqs -nodebuginfo -targetplatform=Android -cookflavor=ETC2 -build -distribution -utf8output -compile

cook Android ASTC包命令:

%EngineDir%\Engine\Binaries\Win64\UE4Editor-Cmd.exe %GameDir%\MyGame.uproject -run=Cook  -TargetPlatform=Android_ASTC -fileopenlog -unversioned -abslog=%EngineDir%\Engine\Programs\AutomationTool\Saved\Cook-2020.12.08-09.48.23.txt -stdout -CrashForUAT -unattended -NoLogTimes  -UTF8Output

注:-iterate参数表示增量cook。在编辑器中打包不会带该参数,会执行全量cook

 

环境变量 -- XXX的用户变量:

ANDROID_HOME    E:\NVPACK\android-sdk-windows
ANDROID_NDK_ROOT    E:\NVPACK\android-ndk-r14b
ANT_HOME     E:\NVPACK\apache-ant-1.8.2
GRADLE_HOME    E:\NVPACK\gradle-2.9
JAVA_HOME    E:\NVPACK\jdk1.8.0_77
NDK_ROOT    E:\NVPACK\android-ndk-r14b
NDKROOT    E:\NVPACK\android-ndk-r14b
NVPACK_NDK_TOOL_VERSION    4.9
NVPACK_NDK_VERSION    android-ndk-r14b
NVPACK_ROOT    E:\\NVPACK
Path    E:\NVPACK\gradle-2.9\bin;E:\NVPACK\apache-ant-1.8.2\bin;E:\NVPACK\jdk1.8.0_77\bin;E:\NVPACK\android-ndk-r14b;E:\NVPACK\android-sdk-windows\extras\android\support;E:\NVPACK\android-sdk-windows\build-tools;E:\NVPACK\android-sdk-windows\platform-tools;E:\NVPACK\android-sdk-windows\tools;

注:若想升级ndk,可从这儿下载,解压后放到E:\NVPACK目录中,并更新NDK_ROOT、NDKROOT及Path环境变量中的路径即可

在项目设置 -- Platforms -- Android页面中,点击Accept SDK License同意一下   注:会在E:\NVPACK\android-sdk-windows\licenses下生成一个android-sdk-license文件

注:可通过执行android-sdk-windows\tools\bin\sdkmanager.bat --licenses来同意license

 

C:\Users\<用户名>\.gradle目录、C:\Users\<用户名>\.android目录

配置gradle的代理(所在文件:C:\Users\<用户名>\.gradle\gradle.properties

systemProp.https.proxyPort=8080
systemProp.http.proxyHost=web-proxy.oa.com
systemProp.https.proxyHost=web-proxy.oa.com
systemProp.http.proxyPort=8080

③ iOS -- Debug版本包  会输出到${IpaDir}/IOS目录中    注:设置DefaultGame.ini中[/Script/UnrealEd.ProjectPackagingSettings]标签下的BuildConfiguration=PPBC_Debug

${%EngineDir%}/Engine/Build/BatchFiles/RunUAT.sh -ScriptsForProject=${GameDir}/MyGame.uproject BuildCookRun -nocompileeditor -nop4 -project=${GameDir}/MyGame.uproject -cook -stage -archive -archivedirectory=${IpaDir} -package -clientconfig=Debug -ue4exe=UE4Editor -compressed -pak -prereqs -nodebuginfo -targetplatform=IOS -build -manifests -CrashReporter -utf8output -compile

注1:在windows配置好iOS远程构建环境,也可以在windows上构建iOS版本  详见:在 Windows 上构建 iOS 版本

注2:Mac上cook失败,提示:CookResults: Error: Package Native Shader Library failed for MacNoEditor.   可通过关掉Project Settings - Packing - Shared Material Native Library来解决

④ Linux ds -- Debug版本包  会输出到${LinuxDir}目录中

${%EngineDir%}/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun -project=${GameDir}/MyGame.uproject -build -cook -pak -stage -archive -archivedirectory=${LinuxDir} -package -serverconfig=Debug -server -noclient -targetplatform=Linux -ue4exe=UE4Editor -prereqs -nop4 -utf8output

注1:cook的临时文件存放在:%GameDir%\Saved\Cooked

注2:最后的版本存放在:%GameDir%\Archive

 

其他

清理Development版本的UE4引擎

"%EngineDir%\Engine\Build\BatchFiles\Clean.bat" UE4Editor Win64 Development -waitmutex

清理Development版本的MyGame项目

"%EngineDir%\Engine\Build\BatchFiles\Clean.bat" MyGameEditor Win64 Development "%GameDir%\MyGame.uproject" -waitmutex

为MyGame项目的TestMap_Main地图构建光照

"%EngineDir%\Engine\Build\BatchFiles\RunUAT.bat" RebuildLightmaps -project=%GameDir%\MyGame.uproject -MapsToRebuildLightMaps=TestMap_Main

在windows上重新打包和重签名,生成ipa文件  注:ipa文件生成在%GameDir%\Binaries\IOS\MyGame.ipa

"%EngineDir%\Engine\Binaries\DotNET\IOS\IPhonePackager.exe" RepackageFromStage "%GameDir%\MyGame.uproject" -config Development -schemename MyGame -schemeconfig "Development" -sign -codebased -stagedir "%GameDir%\Saved\StagedBuilds\IOS" -project "%GameDir%\MyGame.uproject" -provision "DGame.mobileprovision" -certificate "iPhone Developer: cert RDM (CFG5EWN5ME)"

 

找不到XINPUT1_3.dll

安装引擎目录下Engine\Extras\Redist\en-us\UE4PrereqSetup_x64.exe

 

UE4编辑器右击菜单闪烁 无法操作 需要重启或者切换屏幕

mpo_disable.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Dwm]
"OverlayTestMode"=dword:00000005

更多参见:转:UE4编辑器右击菜单闪烁 无法操作 需要重启或者切换屏幕

 

关于解决方案的Configuration

 

1. Debug 游戏模块和引擎模块均开启调试模式

2. DebugGame  游戏模块开启调试模式,引擎模板开启优化

3. Development  游戏模块和引擎模块均开启优化

4. Shipping 发行版本(会去掉所有编辑器功能、stat统计、性能分析以及GM命令等)游戏模块和引擎模块均开启优化

5. Test  含有stat统计、性能分析以及GM命令的Shipping版本

6. 带Editor表示为编辑器版本(含有很多编辑器相关的功能) 使用MyGameEditor.Target.cs的项目配置

7. 带Client表示为客户端版本    使用MyGameClient.Target.cs的项目配置

8. 带Server表示为服务器版本  使用MyGameServer.Target.cs的项目配置

9. 都不带表示为客户端+服务器版本    使用MyGame.Target.cs的项目配置

 

在windows下编译通过,而在其他Linux、Android、iOS等平台编译不过的一些情况:

1. 斜杠问题

如:#include "Misc\FileHelper.h"   -->  #include "Misc/FileHelper.h"

2. 大小写问题

如:#include "HAL/PlatformFileManager.h"  --> #include "HAL/PlatformFilemanager.h"

3. 非英文字符

如:UE_LOG(LogTemp, Warning, TEXT("test xx");  --> UE_LOG(LogTemp, Warning, TEXT("test (xx)");

4. 使用非UE4的类型

如:INT AmmoCount;   -->  int32 AmmoCount;

5. 使用L来修饰字符串

如:L"MyTools"  -->  TEXT("MyTools")

6. 缺少#include某些头文件

原因是不同编译器递归展开头文件规则存在差别

 

Module Circular dependency(模块循环依赖)

UE4中循环依赖的解决方法

 

扩展阅读

Press Button, Drink Coffee : An Overview of UE4 build pipeline and maintenance【CEDEC 2019】

 

posted on 2019-02-12 16:59  可可西  阅读(13066)  评论(0编辑  收藏  举报

导航