定制Unreal Engine 需要发布的必要文件

面向用户

/Engine/Binaries/*

Engine/Plugins/**/Binaries/*

面向游戏开发者

注意:Engine/Binaries/Win64/UnrealEditor-Win64-DebugGame.exe必须上传,否则开发者无法使用DebugGame模式来编译工程

需要发布必要的Lib文件,游戏开发者需要link

Engine/Intermediate/Build/Win64/**.lib

Engine/Plugins/**/Intermediate/Build/Win64/**.lib

发布必要的generated的头文件

Engine/Intermediate/Build/Win64/UnrealEditor/Inc/**.generated.h

Engine/Plugins/**/Intermediate/Build/Win64/UnrealEditor/Inc/**.generated.h

以上文件也可以不发布,游戏开发者自己用脚本生成,速度很快,通常10秒以内可以生成完毕,指令如下:

rem ## allow compile unreal engine
del ..\Engine\Build\InstalledBuild.txt

if exist ..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.exe goto GenHeaders

rem ## start building UnrealBuildTool.exe if it not exist
set ProjectFile="..\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj"
if not exist %ProjectFile% goto NoProjectFile
echo Building UnrealBuildTool with dotnet...
dotnet build %ProjectFile% -c Development -v quiet
if errorlevel 1 goto Error_UBTCompileFailed

rem ## start generate headers of engine.
:GenHeaders
..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.exe -Target="UnrealEditor Win64 Development" -Mode=UnrealHeaderTool -ForceHeaderGeneration -log="../../Projects/Saved/Logs/GenEngineHeaders.log"
:NoProjectFile
rem ## forbidden compile unreal engine
echo. 1> ..\Engine\Build\InstalledBuild.txt
Pause
EXIT /B 0

:Error_UBTCompileFailed
echo ERROR: Failed to build UnrealBuildTool.
echo. 1> ..\Engine\Build\InstalledBuild.txt
EXIT /B 999

避免游戏开发者编译引擎,节约时间,提升效率

需要上传: Engine\Build\InstalledBuild.txt

InstalledBuild.txt在Engine\Build\BatchFiles\Build.bat中引用。

当然,也可以自己创建一个:

echo. 1> ..\Engine\Build\InstalledBuild.txt

InstalledBuild.txt 这个flag文件是用来标记Engine是不是预编译好只专注开发Project的,比如用公版引擎来开发就属于这种情况。

InstalledBuild的主要作用就是跳过UBT的编译,跳过引擎的编译。

蓝图节点跳转Cpp代码

推荐使用InstalledBuild.txt,不建议开启UsePrecompiled!

双击蓝图节点跳转到cpp,前提条件是必须确保你本地所有的Engine的dll文件,都有对应的完整pdb文件。

由于有些项目会和定制Engine放在同一个目录,例如:Projects和Engine在同一个目录下。

此时,当蓝图中双击节点跳转的时候会打开UE5.sln, 而不是YourProjectName.sln。

这个跳转逻辑详见:FVisualStudioSourceCodeAccessor::GetSolutionPath

解决方法:修改Engine\Intermediate\ProjectFiles\PrimaryProjectName.txt的内容,将UE5替换为: Projects/YourProjectName

例如以下脚本:

rem ## fix bug: from blueprint node goto cpp will open a new UE5.sln
echo|set /p="Projects/YourProjectName" 1> ..\Engine\Intermediate\ProjectFiles\PrimaryProjectName.txt

../Engine/Build/BatchFiles/Build.bat  -projectfiles -project="YourProjectName.uproject" -game -rocket -progress -log="Saved/Logs/GeneralteProjLog.log"

关于LivingCode

如果不上传这个InstalledBuild.txt文件,每次Living Code的时候都会编译UnrealBuildTool,并报Access is Denied的错误。

UBT是底层程序,游戏开发者没必要每次都重编UBT,所以InstalledBuild.txt是很有必要存在的。

关于编译UnrealBuildTool.csproj报Access Is Denied的问题,解决办法主要设置Write权限:
Engine\Source\Programs\UnrealBuildTool目录下:所有二进制文件和csproj文件都要设置为可写。

另外,UnrealBuildTool.csproj还依赖Engine/Source/Programs/Shared目录下的一些工程,例如: EpicGames.Build, EpicGames.Core, EpicGames.IoHash, EpicGames.Serialization, EpicGames.UHT, EpicGames.MsBuild.

具体还有哪些文件要设置为可写,用这个命令来判断: dotnet build Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj -c Development -v quiet

关于在编辑器中创建插件

创建插件的方法: Edit菜单 -> Plugins -> Add -> create plugin.

创建插件的原理: FPluginUtils::CreateAndLoadNewPlugin -> FDesktopPlatformBase::GenerateProjectFiles -> FUProjectDictionary::IsForeignProject

为了创建插件后能正确地生成工程文件,就需要删除Engine\Build\SourceDistribution.txt,脚本如下

@echo off
rem ## enable generate uproject files, see @FDesktopPlatformBase::GenerateProjectFiles
echo|set /p="" 1> ..\Engine\Build\SourceDistribution.txt
del ..\Engine\Build\SourceDistribution.txt

第2行是为了确保第3行不会报错。

我的简书: https://www.jianshu.com/p/fb6ccb9f139f

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容