将Unreal Engine项目发布使用之前,必须正确的打包,打包确保所有都是最新的,并能在对应平台上运行的正确格式。以 UE4.19 为例子
- Windows平台
创建包
然后选择一个目录,在UE4 工程右下方会有“正在打包”的提示
生成多个pak包
打包过程遇到的问题
1)Couldn't find parent type for 'K2Node_GetSequenceBinding' named 'UK2Node' in current module or any other module parsed so far
将myproject.Target.cs 原文件如下
修改为:
2)在测试的时候遇到一个错误,提示找不到“HeadMountedDisplayFunctionLibrary.h” 文件,
因为我的项目中用到了UE4.19中 “HeadMountedDisplay” ,vs生成的工程编译没问题,但是打包时,编译报错
所以需要在***.build.cs 文件中PublicDependencyModuleNames 中 添加 HeadMountedDisplay 库
关于使用 “ProjectLauncher” 配置打包环境,在https://blog.csdn.net/zhangxiaofan666/article/details/79567017 中说明很详细了,这里不再描述,感谢作者的总结
- Linux(Centos7)平台——打包server
UE4官方建议使用交叉编译,但是我还是比较偏向于本地编译,完全使用服务器的环境进行编译打包,这只是个人的观点。
安装cmake & clang
cmake 要用3版本以上
clang安装请参考我的另外一篇博文: https://www.cnblogs.com/KisonDu/p/10117262.html
UE4源码安装
1)yum 安装ue4依赖包,否则源码安装会失败
sudo yum install epel-release
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
wget http://copr.fedoraproject.org/coprs/jknife/ue4deps/repo/epel-7/jknife-ue4deps-epel-7.repo
sudo cp jknife-ue4deps-epel-7.repo /etc/yum.repos.d/jknife-ue4deps-epel-7.repo
sudo yum install steam vlc hexchat ntfs-3g mesa-libGLU libXScrnSaver
sudo yum install mono-core mono-devel dos2unix gtk3-devel
2)从github下载 UnrealEngine(github需要与unreal 做绑定,详细请参考官网)
3)编译安装
cd UnrealEngine
./Setup.sh (这一步需要下载将近6G的包)
./GenerateProjectFiles.sh
make -j8 (注意:make的时候不能使用root用户,否则会报错,包含 打包工程都不能用root用户)
此时就会在 Engine/Binaries/Linux 目录下生成 UE4Editor 可执行文件
编译打包
以下是写的简单的shell打包脚本,最重要的就是标红的那一句,命令参数涵义跟windows是一样的
#/bin/bash
type=server
platform=Linux
environment=Development
UATPath="/home/ue4/source/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh"
projectPath=$PWD
pmaps=ThirdPersonExampleMap
$UATPath BuildCookRun -project="$projectPath/RAN_Conqueror.uproject" -noP4 -platform=$platform -clientconfig=$environment -serverconfig=$environment -cook -build -server -nocompileeditor -compressed -stage -package -pak -compile -noclient -serverplatform=$platform -map=$pmaps -unversionedcookedcontent -createreleaseversion=1.0.0 -stagingdirectory="${projectPath}/package/server"
参考文档
UE4官方打包文档:http://api.unrealengine.com/CHN/Engine/Basics/Projects/Packaging/index.html
CSDN: https://blog.csdn.net/zhangxiaofan666/article/details/79567017
命令打包官方文档:https://wiki.unrealengine.com/How_to_package_your_game_with_commands
Dedicated Server Guide (Windows & Linux):
https://wiki.unrealengine.com/Dedicated_Server_Guide_(Windows_%26_Linux)
https://wiki.unrealengine.com/index.php?title=Building_On_Linux