首先是官方wiki的说明
How to package your game with commands
Jump to: navigation, search
Template:Rating This aims to be a quick guide on how to package and distribute your game.
Some points:
-
If you use unreferenced blueprints/objects, you should add them a) using command line or b) by creating a level with all the objects you need to publish in your game (not recomended)
-
Cooking is the proccess of removing unwanted files from your final build
-
You can choose to Pak (like zip) all your content into a single file
-
If you are building a dedicated server, you need to have the compiled version of Unreal or will not work.
-
You will find the RunUAT at UnrealEngine/Engine/Build/BatchFiles
-
Add the command -build if you're using Source Version from Github
-
If the -allmaps flag is used, [AllMaps] with valid +Map=\Game\Maps\Map.umap syntax should be added to DefaultEditor.ini
-
Specific maps can be built (must remove -allmaps flag) using the -maps=Map1+Map2+Map3
Compiling the client (With PAK files):
RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -build -stage -pak -archive -archivedirectory="Output Directory"
Cooking the client (With PAK files):
RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -allmaps -NoCompile -stage -pak -archive -archivedirectory="Output Directory"
Compiling the dedicated server (With PAK files):
RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -server -serverplatform=Win64 -noclient -build -stage -pak -archive -archivedirectory="Output Directory"
Cooking the dedicated server (With PAK files):
RunUAT BuildCookRun -project="full_project_path_and_project_name.uproject" -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -cook -server -serverplatform=Win64 -noclient -NoCompile -stage -pak -archive -archivedirectory="Output Directory"
BuildCookRun 参数:
常用参数如下,详细参数见源文件 Engine\Source\Programs\AutomationTool\AutomationUtils\ProjectParams.cs,注意有些参数不能同时指定,具体见 ValidateAndLog 函数里的参数检查规则。Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs 有一些全局参数定义
整体打包过程如下: Build -> Cook-> Stage -> Package -> Archive
| 基本设置 |
|
| -project=Path | 项目路径(必填) -project=D:\Projects\MyProject.uproject -project="F:/Unreal Projects/testChunk/testChunk.uproject" |
| -noP4(通常都带这个) | -nop4禁用Perforce功能(如果未在构建计算机上运行,则为默认值) |
| -targetplatform(或者-Platform)=PlatformName | 目标平台,定义在枚举 UnrealTargetPlatform 中,包含 Win32/Win64/Mac/XboxOne/PS4/IOS/Android/HTML5/Linux/AllDesktop/TVOS/Switch
-targetplatform=Android |
| -pak | 生成一个pak文件, 是否将资源文件打包到pak中,但是并不是说不指定这个命令行就不用pak,有些平台只能用pak(比如Android打包成apk),不管有没有这个参数,具体见各个平台对 |
| -createreleaseversion=3.0 | 创建release版本3.0,版本信息用于dlc/补丁 |
| -basedonreleaseversion=2.0 | 基于的版本版本信息用于dlc/补丁 |
| -generatepatch | 生成补丁(应不与createreleaseversion 一起使用。) |
| -UTF8Output | log,控制台窗口等输出使用UTF8编码 |
| -p4 | -p4启用Perforce功能(如果在构建计算机上运行,则为默认值) |
| -servertargetplatform (或者-ServerPlatform)=PlatformName | Dedicated Server 目标平台,定义同上 |
|
|
|
| -clean | (在构建之前擦除intermediate文件夹)重新完整构建 |
| -signpak=keys | sign the generated pak file with the specified key, i.e. -signpak=C:\Encryption.keys. Also implies -signedpak. -SignPak=C:\Encryption.keys 或者 -signpak=0x…..: 指定加密pak文件密钥内容或者密钥文件路径,密钥内容以 0x 开头,同时 -SignedPak 参数也生效 |
| -signed | 游戏应该使用加密的pak文件 |
| -skippak | 不生成pak,使用上一次的构建的pak文件,包含-Pak |
| -CrashReporter | 构建CrashReporter |
| Build相关参数 |
|
| -build | 执行编译过程 |
| -clientconfig=Development | 客户端编译的构建配置DebugGame/Development/Shipping |
| -serverconfig=Development | 服务器编译的构建配置DebugGame/Development/Shipping |
| -NoCompile | 跳过编译(纯蓝图项目) |
| -SkipBuildClient | 不编译客户端 |
| -SkipBuildEditor | 不编译编辑器 |
| -noxge | 不执行并行编译 |
| -ForceDebugInfo | 在非Debug版本中加入调试信息Forces debug info even in development builds |
| Cook 相关参数 |
|
| -cook, | 使用Cooked资源 |
| -CookFlavor= | -CookFlavor=Multi/ATC/DXT/ETC1/ETC2/PVRTC/ASTC: 指定Android Cook格式 |
| -MapsToCook= | -MapsToCook=map1+map2+map3: 指定要cook的关卡,多个之间用+号连接 |
| -Compressed | : 压缩 |
| -UnversionedCookedContent | 不包含版本号 |
| -SkipCookingEditorContent | 在烘焙时跳过/Engine/Editor文件夹中的内容(Skips content under /Engine/Editor when cooking) 不cook引擎编辑器使用到的资源 |
| -CookAll | 烘培content文件夹中的所有东西 |
| -CookMapsOnly | 只cook关卡和关卡引用到的资源,只会在同时指定了-CookAll时生效 |
| -manifests | 在cooking data时生成 流安装(streaming install) manifests |
| -createchunkinstall | 在cooking data时生成流安装(streaming install)数据, 需要 -stage和-manifests |
| -skipcook | 跳过cook阶段,使用上一次Cook好的资源,同时包含了 -Cook 参数 |
| -CookOutputDir=path | -CookOutputDir=C:\cooked: 指定cook结果保存目录,默认在Project/Saved/Cooked(使用UAT cook)和Project/Saved/EditorCooked(使用editor cook) |
| -CookInEditor | 使用editor进行cook而不是UAT |
| -ue4exe=ExecutableName | -ue4exe="D:\Program Files\Epic Games\UE_4.22\Engine\Binaries\Win64\UE4Editor-Cmd.exe"
指定ue4 Editor 的可执行文件路径 |
| -IgnoreCookErrors | 忽略cook 错误 |
| -CookPartialgc | cook阶段磁盘空间不够不要清理所有资源 |
| -AdditionalCookerOptions | -AdditionalCookerOptions=xxx: 额外的传给cooker进程的命令行 |
| -FastCook | 开启FastCook,如果项目支持的话 |
| -NumCookersToSpawn | 指定cooker进程的数量 |
| -iterativecooking(或者-iterate) | 迭代烘培 |
| -EncryptIniFiles: | 加密ini文件,只在指定了加密密钥和使用pak文件时候有效 |
| -EncryptEverything | 加密所有的文件,只在指定了加密密钥和使用pak文件时候有效 |
| -EncryptPakIndex | 加密pak索引,只在指定了加密密钥和使用pak文件时候有效 |
| Stage相关参数 |
|
| -stage | 保存构建过程中的中间结果 |
| -stagingdirectory=Path | -StagingDirectory=C:\xxxx: 构建过程中中间结果保存目录,默认在ProjectPath\Saved\StagedBuilds |
| -skipstage | 不保存构造过程中的中间结果,使用上一次的结果,这个命令行同时包含了 -Stage |
| -nodebuginfo | 不拷贝调试信息文件到Stage目录,也就是最终打出来的包中不包含调试信息 |
| -nocleanstage | 新构建不会清理之前StagingDirectory中的文件, 如果指定了-clean则一定会清理掉 |
| -StageCommandline= | -StageCommandline=xxxx: 放在UE4CommandLine.txt中的一系列命令行,打出来的包在运行时会从这个文件中读取命令行并执行 |
| Package相关参数 |
|
| -package | 执行打包 Andorid->apk, iOS->ipa |
| -distribution | 打的包是发布版本,在Android和iOS上会禁掉Debugable属性 |
| -prereqs | 指定打包游戏是否包含先决条件的安装文件(例如支持平台上的操作系统可发布组件) |
| -applocaldir | 指定是否在游戏可执行文件中包含先決条件。 |
| -AdditionalPackageOptions | 给平台打包器的额外参数(extra options to pass to the platform's packager) |
| Archive相关参数 |
|
| -archive | 将构建结果归档 |
| -archivedirectory=Path | 归档目录,默认为ProjectPath\ArchivedBuilds |
| -bundlename | 部署到移动设备上时使用的使用的绑定名称 string to use as the bundle name when deploying to mobile device |
| -createappbundle | When archiving for Mac, set this to true to package it in a .app bundle instead 当目标平台是Mac时,指定这个参数可以归档成一个 .app 文件而不是一堆散文件 |
| Run相关参数 |
|
| -run | 构建之后运行游戏 |
| -cookonthefly | 使用在服务器上提供的cook过的资源进行游戏 |
| -Cookontheflystreaming | 同上,但是不缓存资源到本地 |
| -fileserver | 使用UnrealFileServer上的cook过的资源数据 |
| -dedicatedserver(或者-server) | 构建 cook 并运行客户端和服务器 |
| -client | build, cook and run a client and a server, uses client target configuration |
| -noclient | do not run the client, just run the server |
| -logwindow | 为客户端创建log窗口 |
| -map | 指定游戏运行的关卡 |
| -device | Devices to run the game on |
| -serverdevice | Device to run the server on |
| -skipserver | Skip starting the server |
| -AdditionalServerMapParams | Additional server map params, i.e ?param=value |
| -numclients=n | Start extra clients, n should be 2 or more |
| -addcmdline | Additional command line arguments for the program |
| -servercmdline | Additional command line arguments for the program |
| -clientcmdline | Override command line arguments to pass to the client |
| Deploy相关参数 |
|
| -deploy | 部署 |
| -DeployFolder= | 部署路径 |
| Other |
|
| -destsample | Destination Sample name(目标样本名称) |
| -foreigndest | Foreign Destination |
| -foreign | Generate a foreign uproject from blankproject and use that |
| -foreigncode | Generate a foreign code uproject from platformergame and use that |
| -skipcookonthefly | 在cookonthefly构建中,仅用于将信息传递给包装步骤 |
| -unattended | assumes no operator is present, always terminates without waiting for something. |
| -prepak | 试图避免cooking,而是从网络中提取pak文件,包含了-pak和-skipcook。 |
| -separatedebuginfo | output debug info to a separate directory |
| -MapFile | generates a *.map file |
| -Prebuilt | this is a prebuilt cooked and packaged build |
| -getfile | download file from target after successful run |
| -IgnoreLightMapErrors | 是否应将Light Map错误视为关键错误 |
| -archivemetadata | Archive extra metadata files in addition to the build (e.g. build.properties) 存档除了构建之外的额外元数据文件(例如build.properties) |
| -cmdline | 命令行写入 stage 文件夹中的 UE4CommandLine.txt |
| -nullrhi | add -nullrhi to the client commandlines |
| -fakeclient | adds ?fake to the server URL |
| -editortest | rather than running a client, run the editor instead |
| -RunAutomationTests | when running -editortest or a client, run all automation tests, not compatible with -server |
| -Crash=index | when running -editortest or a client, adds commands like debug crash, debug rendercrash, etc based on index |
| -deviceuser | Linux username for unattended key genereation |
| -devicepass | Linux password |
| -RunTimeoutSeconds | timeout to wait after we lunch the game |
| -SpecifiedArchitecture | Determine a specific Minimum OS |
| -UbtArgs | extra options to pass to ubt |
| -MapsToRebuildLightMaps | List of maps that need light maps rebuilding |
| -MapsToRebuildHLODMaps | List of maps that need HLOD rebuilding |
| -ForceMonolithic | Toggle to combined the result into one executable |
| -ForceNonUnity | Toggle to disable the unity build system |
| -ForceUnity | Toggle to force enable the unity build system |
| -Licensee | If set, this build is being compiled by a licensee |
| -NoSign | Skips signing of code/content files. |

本文详细介绍如何使用Unreal Engine 4 (UE4)的命令行工具BuildCookRun来打包游戏,包括编译、烹饪资源、阶段化、打包和归档等步骤。提供了针对不同平台如Windows、Android和iOS的特定参数,以及如何处理pak文件、加密和调试信息等内容。

1万+

被折叠的 条评论
为什么被折叠?



