Unreal相关随记
Offline Document - 离线文档
Engine\Documentation\Builds\BlueprintAPI-HTML.tgz
Engine\Documentation\Builds\CppAPI-HTML.tgz
设置 VS IDE
- https://docs.unrealengine.com/4.27/zh-CN/ProductionPipelines/DevelopmentSetup/VisualStudioSetup/
- 安装扩展程序
[UE4RootLocation]\Engine\Extras\UnrealVS\UnrealVS.vsix
- 改善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
使用ShaderCompilerWorker.exe编译shader
1
%EngineDir%/Engine/Binaries/Win64/ShaderCompileWorker.exe <AppData>/Local/Temp/UnrealShaderWorkingDir/BFE18CAA45FA658BF12AE489BE247311/5/ 27472 5 WorkerInputOnly.in WorkerOutputOnly.out -communicatethroughfile -TimeToLive=20.000000 -Multiprocess
使用UnrealVersionSelector添加引擎到注册表并在资源管理器上下文菜单中添加引擎快捷功能
使用UnrealVersionSelector添加引擎到注册表并在资源管理器上下文菜单中添加引擎快捷功能
1
"%EngineDir%\Engine\Binaries\DotNET\UnrealVersionSelector.exe" /register
- 对uproject文件进行右键菜单注册
- 注册uproject文件所用的引擎路径
编译引擎和项目
log文件在UnrealEngine\Engine\Programs\UnrealBuildTool\Log.txt目录中
UBT使用ActionGraph分析模块的代码是否需要Outdated,然后执行lib、pdb的清理工作
对比UnrealEngine\Engine\Intermediate\Build\Win64\UnrealHeaderTool\DebugGame\UnrealHeaderTool中的Definitions.h和Definitions.h.old文件来决定是否需要重编译
生成了UE4.sln或UE4.xcworkspace,也可以使用msbuild.exe或xcodebuild来编译
1 2 3 4
// 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的Development Android版本(libUE4.so)
1
UnrealBuildTool.exe MyGame Android Development -Project=%GameDir%\MyGame.uproject"
编译项目MyGame的Debug IOS版本(MyGame可执行二进制)
1
mono $EngineDir$/Engine/Binaries/DotNET/UnrealBuildTool.exe MyGame IOS Debug -Project=$GameDir$/MyGame.uproject
遇到的问题:ld: can’t open -unexported_symbols_list file: /Users/xxx/Trunk/UAGroup/MyGame/unexported_symbols.txt
解决方法:在该目录下放置一个unexported_symbols.txt文件,里面内容如下:
1
2
3
4
5
6
7
8
9
10
*TSS*
*Tss*
*tss*
*AceSDK*
*MRPCS*
*mrpcs*
*tp2*
*tcj*
*_proto*
*ns_tinyxml*
编译单个c/cpp文件
1
"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" MyGameEditor Win64 Development "%GameDir%\MyGame.uproject" -singlefile="%GameDir%\Source\MyGame\MyGameCharacter.cpp" -WaitMutex -FromMsBuild -DEPLOY
编译单个模块
1
"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" -Module=MyGame Win64 Development -TargetType=Editor -Project="%GameDir%\MyGame.uproject" -canskiplink "%GameDir%\MyGame.uproject"
编译单个引擎模块
1
"%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" -Module=Engine Win64 Development -TargetType=Editor -Project="%GameDir%\MyGame.uproject" -canskiplink -nosharedpch "%GameDir%\MyGame.uproject"
编译多个模块
1
"%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=、-Makefile、-CMakefile、-QMakefile、-KDevelopfile、-CodeliteFiles、-XCodeProjectFiles、-EdditProjectFiles、-VSCode、-VSMac、-CLion
注2:更多额外命令行参数见UnrealBuildTool中的TargetDescriptor类中的CommandLine修饰的成员变量
- -NoHotReload、-ForceHotReload、-LiveCoding、-WriteActions=c:\myAction.txt (输出编译链接过程中详细信息)-mode=JsonExport(读取所有build.cs,输出modules的依赖关系)、-LiveCodingModules=modulelist.txt、-LiveCodingManifest=mymenifest.txt、-Quiet
1
2
3
4
5
# 编译链接出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的客户端版本
1
"%EngineDir%\Engine\Binaries\Win64\UnrealVersionSelector.exe" MyGame Win64 Development -Project="%GameDir%\MyGame.uproject"
编译项目MyGame的Linux Server版本
1
mono "%EngineDir%\Engine\Binaries\DotNET\UnrealBuildTool.exe" MyGameServer Linux Development -Project="%GameDir%\MyGame.uproject"
构建安装版引擎
1
%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目录中
代码被优化无法调试
xx.build.cs
1
OptimizeCode = CodeOptimization.InShippingBuildsOnly;