引子
- 背景
在使用UE5引擎开发游戏时,会常常遇到需要在真机上快速验证个别资源的情况。随着项目的资源的膨胀,往往从编译-->>Cook-->>出包这个流程会花费大量的时间。 - 痛点
若真机出现问题,修复 -> 重新出包 -> 验证,这个流程就会变得极为冗长。并且经常会遇到脚本、数据或者某些的资源错误,导致包的异常。虽然UE本身做了缓存,但还是可能因为一些修改导致重新Cook。这种情况下,再完整出一个包就等待数个小时的时间,导致测试无法进行冒烟跑测。就算重新出包也难保一定没有其他遗漏的问题,否则又要重来一遍。 - 本文内容
基于上述痛点,迫切地需要一种在开发阶段能够快速地修复包内资源问题,进行快速验证的方法。
本篇文章会介绍,如何使用UE5的命令行,来快速打包特定资源。如果能充分利用起来,就不必等待完整出包,加速资源在真机上的验证流程,大幅提升测试效率。
一、UE5的打包流程(以安卓为例)
1. 当点击Package Project时,观察Console Log
通过日志,简单可以总结流程:
- 编译/构建-->>Cook资源-->>创建Pak-->>创建Apk
本文中,只需要关心资源的Cook和创建Pak的流程
- 以下截取了Package部分关键命令,其中通过!!!标注重点命令
...略...
[2024.12.04-07.30.25:065][0]LogMonitoredProcess: Running Serialized UAT: [ cmd.exe /c ""D:/Trunk/trunk/UnrealEngine-5.4/Engine/Build/BatchFiles/RunUAT.bat" -ScriptsForProject="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" Turnkey -utf8output -WaitForUATMutex -command=VerifySdk -ReportFilename="D:/UEProjects/PackProjectTest/Intermediate/TurnkeyReport_0.log" -log="D:/UEProjects/PackProjectTest/Intermediate/TurnkeyLog_0.log" -project="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" -platform=all" ]
...略...
[2024.12.04-07.30.42:090][0]LogMonitoredProcess: Running Serialized UAT: [ cmd.exe /c ""D:/Trunk/trunk/UnrealEngine-5.4/Engine/Build/BatchFiles/RunUAT.bat" -ScriptsForProject="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" Turnkey -utf8output -WaitForUATMutex -command=VerifySdk -ReportFilename="D:/UEProjects/PackProjectTest/Intermediate/TurnkeyReport_1.log" -log="D:/UEProjects/PackProjectTest/Intermediate/TurnkeyLog_1.log" -project="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" -Device=Win64@DESKTOP-2UNRKBE" -nocompile -nocompileuat ]
...略...
[2024.12.04-07.40.11:244][60]LogMonitoredProcess: Running Serialized UAT: [ cmd.exe /c ""D:/Trunk/trunk/UnrealEngine-5.4/Engine/Build/BatchFiles/RunUAT.bat" -ScriptsForProject="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" Turnkey -command=VerifySdk -platform=Android -UpdateIfNeeded -EditorIO -EditorIOPort=55904 -project="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" BuildCookRun -nop4 -utf8output -nocompileeditor -skipbuildeditor -cook -project="D:/UEProjects/PackProjectTest/PackProjectTest.uproject" -target=PackProjectTest -unrealexe="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe" -platform=Android -cookflavor=ASTC -stage -archive -package -build -pak -iostore -compressed -prereqs -archivedirectory="D:/UEProjects/PackProjectTest/build" -clientconfig=Development" -nocompile -nocompileuat ]
[2024.12.04-07.40.11:281][60]UATHelper: Packaging (Android (ASTC)): Running AutomationTool...
...略...
[2024.12.04-07.40.11:842][95]UATHelper: Packaging (Android (ASTC)): Cleaning Temp Paths...
[2024.12.04-07.40.11:842][95]UATHelper: Packaging (Android (ASTC)): BUILD SUCCESSFUL
[2024.12.04-07.40.11:853][97]UATHelper: Packaging (Android (ASTC)): Setting up ProjectParams for D:\UEProjects\PackProjectTest\PackProjectTest.uproject
[2024.12.04-07.40.13:169][254]UATHelper: Packaging (Android (ASTC)): ********** BUILD COMMAND STARTED **********
[2024.12.04-07.40.13:191][257]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\ThirdParty\DotNet\6.0.302\windows\dotnet.exe "D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -Target="UnrealPak Win64 Development -Project=D:\UEProjects\PackProjectTest\PackProjectTest.uproject -Manifest=D:\Trunk\trunk\UnrealEngine-5.4\Engine\Intermediate\Build\Manifest-1-UnrealPak-Win64-Development.xml" -Target="PackProjectTest Android Development -Project=D:\UEProjects\PackProjectTest\PackProjectTest.uproject -Manifest=D:\Trunk\trunk\UnrealEngine-5.4\Engine\Intermediate\Build\Manifest-2-PackProjectTest-Android-Development.xml -remoteini=\"D:\UEProjects\PackProjectTest\" -skipdeploy " -log="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\UBA-UnrealPak-Win64-Development.txt"
...略...
[2024.12.04-07.45.36:704][487]UATHelper: Packaging (Android (ASTC)): Total time in Parallel executor: 314.91 seconds
[2024.12.04-07.45.36:715][487]UATHelper: Packaging (Android (ASTC)): Total execution time: 323.48 seconds
[2024.12.04-07.45.36:737][488]UATHelper: Packaging (Android (ASTC)): Took 323.57s to run dotnet.exe, ExitCode=0
[2024.12.04-07.45.36:758][488]UATHelper: Packaging (Android (ASTC)): Build command time: 323.60 s
[2024.12.04-07.45.36:758][488]UATHelper: Packaging (Android (ASTC)): ********** BUILD COMMAND COMPLETED **********
[2024.12.04-07.45.36:758][488]UATHelper: Packaging (Android (ASTC)): ********** COOK COMMAND STARTED **********
[2024.12.04-07.45.36:769][488]UATHelper: Packaging (Android (ASTC)): Running UnrealEditor Cook for project D:\UEProjects\PackProjectTest\PackProjectTest.uproject
[2024.12.04-07.45.36:769][488]UATHelper: Packaging (Android (ASTC)): Commandlet log file is D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Cook-2024.12.04-15.45.36.txt
!!![2024.12.04-07.45.36:769][488]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unversioned -fileopenlog -abslog="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Cook-2024.12.04-15.45.36.txt" -stdout -CrashForUAT -unattended -NoLogTimes -UTF8Output
[2024.12.04-07.45.37:033][488]UATHelper: Packaging (Android (ASTC)): LogInit: Display: Running engine for game: PackProjectTest
...略...
[2024.12.04-07.45.56:361][546]UATHelper: Packaging (Android (ASTC)): ********** COOK COMMAND COMPLETED **********
[2024.12.04-07.45.56:361][546]UATHelper: Packaging (Android (ASTC)): ********** STAGE COMMAND STARTED **********
...略...
!!![2024.12.04-07.45.56:709][547]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json" -patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid -platform=Android -CreateMultiple="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\PakCommands.txt"
...略...
!!![2024.12.04-07.45.57:460][550]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe -CreateGlobalContainer="D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\global.utoc" -CookedDirectory="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC" -PackageStoreManifest="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\packagestore.manifest" -Commands="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\IoStoreCommands.txt" -ScriptObjects="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\scriptobjects.bin" -patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json" -compressionMinBytesSaved=1024 -compressionMinPercentSaved=5 -WriteBackMetadataToAssetRegistry=Disabled
...略...
[2024.12.04-07.45.58:015][551]UATHelper: Packaging (Android (ASTC)): ********** STAGE COMMAND COMPLETED **********
[2024.12.04-07.45.58:015][551]UATHelper: Packaging (Android (ASTC)): ********** PACKAGE COMMAND STARTED **********
...略...
[2024.12.04-07.46.38:571][962]UATHelper: Packaging (Android (ASTC)): ********** PACKAGE COMMAND COMPLETED **********
[2024.12.04-07.46.38:571][962]UATHelper: Packaging (Android (ASTC)): ********** ARCHIVE COMMAND STARTED **********
...略...
[2024.12.04-07.46.38:637][962]UATHelper: Packaging (Android (ASTC)): ********** ARCHIVE COMMAND COMPLETED **********
[2024.12.04-07.46.38:637][962]UATHelper: Packaging (Android (ASTC)): BuildCookRun time: 386.79 s
[2024.12.04-07.46.38:637][962]UATHelper: Packaging (Android (ASTC)): BUILD SUCCESSFUL
[2024.12.04-07.46.38:637][962]UATHelper: Packaging (Android (ASTC)): AutomationTool executed for 0h 6m 27s
[2024.12.04-07.46.38:637][962]UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=0 (Success)
2. 资源更新替换原理
通常情况下,游戏程序都是从默认资源路径下去读取资源,这样要替换某个资源,就需要在默认路径下直接的替换资源。但是在进行游戏打包的时候,会把许多资源合起来打包在一起,此时如果需要通过默认路径的方法更新该资源,就需要把与之绑定在一起的资源都重新打包一次。
因此引擎停供了一种方案,在读取某个资源的时候,从优先级更高的路径中先尝试获取一下资源,若获取到资源,则直接使用,否则再从默认资源路径下去获取。
基于此原理,在进行局部资源更新替换,其实就是把资源单独封装后,挂载到加载优先级更高的目录中,以达到资源替换的目的。
优先级更高的挂载目录
- 手机平台
/sdcard/Android/data/com.[Company].[ProjectName]/files/UnrealGame/[ProjectName]/[ProjectName]/Saved/Paks/
3. 打包参数配置
在解析命令前,还有一个关键的配置需要强调一下。如果打包开启IOStore,则后续局部文件打包的流程也不尽相同,以下主要介绍开启IOStore的情形。
Note:未开启IOStore的情形只需要按照以下流程重新封装命令即可实现
二、Cook资源命令解析
1. 截取的Cook命令
!!![2024.12.04-07.45.36:769][488]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unversioned -fileopenlog -abslog="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Cook-2024.12.04-15.45.36.txt" -stdout -CrashForUAT -unattended -NoLogTimes -UTF8Output
以上是完整的Cook命令,下面简化了命令
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unattended -unversioned
2. Cook命令的可选参数
可在源码CookCommandlet.cpp中找到相关可选参数
3. 封装打包局部资源的Cook命令
- 完整命令结构
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unattended -unversioned -DisableUnsolicitedPackages -cooksinglepackage -Map=[Map Name]
- 新增参数
-DisableUnsolicitedPackages -cooksinglepackage -Map=[MapName]
这里关键如何构造MapName,单文件和多文件的格式是怎样的?
- 两种资产路径的复制的方法(Copy Reference和Copy File Path)
- Copy Reference : /Script/Engine.Blueprint'/Game/ThirdPerson/Blueprints/GOODItems.GOODItems'
- Copy File Path: D:/UEProjects/PackProjectTest/Content/ThirdPerson/Blueprints/GOODItems.uasset
- 单个资源Cook示例bat
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unattended -unversioned -DisableUnsolicitedPackages -cooksinglepackage -Map=/Game/ThirdPerson/Blueprints/GOODItems
- 多个资源Cook示例bat
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealEditor-Cmd.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -run=Cook -TargetPlatform=Android_ASTC -unattended -unversioned -DisableUnsolicitedPackages -cooksinglepackage -Map=/Game/ThirdPerson/Blueprints/GOODItems+/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter
- Map参数构造方法
参考以上示例,通过Copy Reference格式复制资源路径,再通过"+"拼接多个资源。
Note:如果是插件Content目录下的资源,同样是通过Copy Reference的格式复制资源路径
4. Cook结果
通过以上Cook命令,可只Cook:GOODItems+BP_ThirdPersonCharacter资源到[ProjectDir]/Saved/Cooked/相关路径下
三、UnrealPak命令解析(IOStore)
1. 截取的Pak命令
区别于Cook命令,UnrealPak.exe调用了两次
- 第一次Pak:
!!![2024.12.04-07.45.56:709][547]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json" -patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid -platform=Android -CreateMultiple="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\PakCommands.txt"
- 第二次Pak:
!!![2024.12.04-07.45.57:460][550]UATHelper: Packaging (Android (ASTC)): Running: D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe -CreateGlobalContainer="D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\global.utoc" -CookedDirectory="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC" -PackageStoreManifest="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\packagestore.manifest" -Commands="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\IoStoreCommands.txt" -ScriptObjects="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\scriptobjects.bin" -patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json" -compressionMinBytesSaved=1024 -compressionMinPercentSaved=5 -WriteBackMetadataToAssetRegistry=Disabled
2. 命令解析
2.1 为什么会调用两次呢?
- 其实这个跟上述提到的是否开启IOStore有关。若未开启IOStore则只需要执行第一次Pak命令。这里以开启IOStore的情况进行说明
2.2 两次命令需要关心的参数内容有哪些?
- 第一次命令: -CreateMultiple="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\PakCommands.txt"
- 第二次命令:-Commands="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\Logs\IoStoreCommands.txt"
2.3 4个txt文件
- PakCommands.txt
"D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\PackProjectTest-Android_ASTC.pak" -create="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\ResponseFiles\PakList_PackProjectTest-Android_ASTC.txt"
- IoStoreCommands.txt
-Output="D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\PackProjectTest-Android_ASTC.utoc" -ContainerName=PackProjectTest-Android_ASTC -ResponseFile="D:\Trunk\trunk\UnrealEngine-5.4\Engine\Programs\AutomationTool\Saved\ResponseFiles\PakListIoStore_PackProjectTest-Android_ASTC.txt"
通过以上分析,又发现了两个txt需要关注,这里截取部分txt内容
- PakList_PackProjectTest-Android_ASTC.txt
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Content\Slate\Automation\DeveloperDirectoryContent.png" "../../../Engine/Content/Slate/Automation/DeveloperDirectoryContent.png" -compress
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Content\Slate\Automation\EditorGroupBorder.png" "../../../Engine/Content/Slate/Automation/EditorGroupBorder.png" -compress
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Content\Slate\Automation\ErrorFilter.png" "../../../Engine/Content/Slate/Automation/ErrorFilter.png" -compress
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Content\Slate\Automation\ExcludedTestsFilter.png" "../../../Engine/Content/Slate/Automation/ExcludedTestsFilter.png" -compress
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Content\Slate\Automation\Fail.png" "../../../Engine/Content/Slate/Automation/Fail.png" -compress
...略...
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Plugins\MeshPainting\MeshPainting.uplugin" "../../../Engine/Plugins/MeshPainting/MeshPainting.uplugin" -compress
"D:\Trunk\trunk\UnrealEngine-5.4\Engine\Plugins\Messaging\TcpMessaging\TcpMessaging.uplugin" "../../../Engine/Plugins/Messaging/TcpMessaging/TcpMessaging.uplugin" -compress
...略...
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\Engine\Config\BaseInput.ini" "../../../Engine/Config/BaseInput.ini" -compress
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\Engine\Config\BaseInstallBundle.ini" "../../../Engine/Config/BaseInstallBundle.ini" -compress
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\Engine\Config\BaseRuntimeOptions.ini" "../../../Engine/Config/BaseRuntimeOptions.ini" -compress
...略...
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\PackProjectTest\Config\DefaultEngine.ini" "../../../PackProjectTest/Config/DefaultEngine.ini" -compress
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\PackProjectTest\Config\DefaultGame.ini" "../../../PackProjectTest/Config/DefaultGame.ini" -compress
"D:\UEProjects\PackProjectTest\Saved\Temp\Android\PackProjectTest\Config\DefaultInput.ini" "../../../PackProjectTest/Config/DefaultInput.ini" -compress
通过对文件后缀的分析,发现此文件主要存放一些非uasset后缀的文件
- PakListIoStore_PackProjectTest-Android_ASTC.txt
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\Engine\Content\EngineMaterials\BaseFlattenEmissiveMap.uasset" "../../../Engine/Content/EngineMaterials/BaseFlattenEmissiveMap.uasset" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\Engine\Content\EngineMaterials\BaseFlattenEmissiveMap_VT.uasset" "../../../Engine/Content/EngineMaterials/BaseFlattenEmissiveMap_VT.uasset" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\Engine\Content\EngineMaterials\BaseFlattenGrayscaleMap.uasset" "../../../Engine/Content/EngineMaterials/BaseFlattenGrayscaleMap.uasset" -compress
...略...
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Content\Characters\Mannequins\Textures\Quinn\T_Quinn_02ID_MSR_MSK.ubulk" "../../../PackProjectTest/Content/Characters/Mannequins/Textures/Quinn/T_Quinn_02ID_MSR_MSK.ubulk" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Content\Characters\Mannequins\Textures\Quinn\T_Quinn_02ID_N.uasset" "../../../PackProjectTest/Content/Characters/Mannequins/Textures/Quinn/T_Quinn_02ID_N.uasset" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Content\Characters\Mannequins\Textures\Quinn\T_Quinn_02ID_N.ubulk" "../../../PackProjectTest/Content/Characters/Mannequins/Textures/Quinn/T_Quinn_02ID_N.ubulk" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Content\Characters\Mannequins\Textures\Quinn\T_Quinn_02ID_Tan.uasset" "../../../PackProjectTest/Content/Characters/Mannequins/Textures/Quinn/T_Quinn_02ID_Tan.uasset" -compress
"D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Content\Characters\Mannequins\Textures\Quinn\T_Quinn_02ID_Tan.ubulk" "../../../PackProjectTest/Content/Characters/Mannequins/Textures/Quinn/T_Quinn_02ID_Tan.ubulk" -compress
此文件主要存放uasset、ubulk后缀的资源
3. 封装打包局部资源的Pak命令
命中[]需要替换为对应内容
3.1 第一次UnrealPak
- 命令
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe "D:\UEProjects\PackProjectTest\PackProjectTest.uproject" -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json"
-patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid
-platform=Android
-CreateMultiple=[PakCommands.txt Path]
- PakCommands.txt构造
"D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\[PakName].pak" -create=[PakList_PackProjectTest-Android_ASTC.txt Path]
一般PakName格式:PatchName_Android_ASTC_1_P,[Patch名字]_[平台]_[版本号]_P
- PakList_PackProjectTest-Android_ASTC.txt构造
示例格式
[Cook Path]/[ProjectName]/xxx.ini .../.../.../[ProjectName]/xxx.ini -compress
3.2 第二次UnrealPak(IOStore)
- 命令
D:\Trunk\trunk\UnrealEngine-5.4\Engine\Binaries\Win64\UnrealPak.exe -CreateGlobalContainer="D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\global.utoc" -CookedDirectory="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC" -PackageStoreManifest="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\packagestore.manifest"
-Commands=[IoStoreCommands.txt Path] -ScriptObjects="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\scriptobjects.bin"
-patchpaddingalign=0 -compressionformats=Oodle -compresslevel=4 -compressmethod=Mermaid -cryptokeys="D:\UEProjects\PackProjectTest\Saved\Cooked\Android_ASTC\PackProjectTest\Metadata\Crypto.json" -compressionMinBytesSaved=1024 -compressionMinPercentSaved=5 -WriteBackMetadataToAssetRegistry=Disabled
- IoStoreCommands.txt构造
-Output="D:\UEProjects\PackProjectTest\Saved\StagedBuilds\Android_ASTC\PackProjectTest\Content\Paks\[utocName].utoc" -ContainerName=PackProjectTest-Android_ASTC -ResponseFile=[PakListIoStore_PackProjectTest-Android_ASTC.txt Path]
utocName:PatchName_Android_ASTC_1_P,[Patch名字]_[平台]_[版本号]_P
- PakListIoStore_PackProjectTest-Android_ASTC.txt构造
示例格式
[Cook Path]/[ProjectName]/xxx.uasset .../.../.../[ProjectName]/xxx.uasset -compress
[Cook Path]/[ProjectName]/xxx.ubulk .../.../.../[ProjectName]/xxx.ubulk -compress
Pak结果
需要将pak、ucas、utoc都拷贝至Saved/Paks目录下,实现局部资源更新
四、Py集成工具
五、总结
本文通过对UE5标准的打包命令进行阅读解析,再稍加修改就可以得到局部资源打包的方法。有了封装后的脚本,便可快速的对局部资源进行验证、修复,大大减少后期工程需要对个别资源快速验证的时间。