> For the complete documentation index, see [llms.txt](https://docs.edgegap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgegap.com/zh/unreal-engine/geng-duo-gou-jian-fang-shi.md).

# 更多构建方式

这些方法通常更慢，并且需要对 Unreal Engine 有更深入的理解。

{% hint style="success" %}
参见 [Unreal Engine](/zh/unreal-engine.md) 用于你在 Edgegap 上使用 Unreal Engine 游戏服务器托管的第一步。
{% endhint %}

探索适用于更高级 Unreal Engine 和 Edgegap 用户的替代构建方法：

1. [#build-with-scripts](#build-with-scripts "mention") 是一种快速且自动化的方法，适用于持续集成。
2. [#build-from-plugin](#build-from-plugin "mention") 是一种传统的构建方法，需要从源码构建 Unreal Engine。

## ⚡ 使用脚本构建

使用脚本构建是一种快速、全自动且简单的方法，适用于持续集成。

### 准备工作 <a href="#scripts-before-starting" id="scripts-before-starting"></a>

### 1. 配置项目 <a href="#scripts-configure-game-builds" id="scripts-configure-game-builds"></a>

### 2. 构建并发布 <a href="#scripts-build-and-upload-to-edgegap" id="scripts-build-and-upload-to-edgegap"></a>

☑️ **验证 Docker 已安装并正在运行。**

{% embed url="<https://github.com/edgegap/edgegap-unreal-buildutils>" %}

☑️ **下载我们的 Edgegap Build Utils** 包括：

* 平台特定的构建脚本：
  * `BuildAndUpload.ps1`  适用于 Windows，
  * `BuildAndUpload.sh`  适用于 macOS 和 Linux，
* `Dockerfile`  - 用于构建 Docker 镜像的配置文件，
* `dockerignore`  - 要移除以加快构建速度的非关键文件列表，
* `StartServer.sh`  - 在运行时管理 Unreal Engine 生命周期的实用脚本。

☑️ **移动 `edgegap-unreal-buildutils` 文件夹到你的项目根目录。**

☑️ **编辑 `BuildAndUpload`  脚本，针对你的平台** 以配置：

* 用于拉取适用于 Linux 服务器的预构建 Unreal Engine 镜像的 GitHub 凭据，
* 项目详情 - 引擎版本、服务器配置、.uproject 文件名，
* [Edgegap Registry](https://app.edgegap.com/registry-management/repositories/list) 用于上传已完成构建的凭据。

☑️ **执行已编辑的脚本** 以开始构建和上传流程。完成此步骤后，将会添加一个新的 **镜像到你的** [仓库中的 Edgegap Container Registry 仪表板页面](https://app.edgegap.com/registry-management/repositories/list).

☑️ 你将自动跳转到 **创建一个新的** [应用与版本](/zh/learn/bian-pai/application-and-versions.md#app-versions) 在 [控制台](https://app.edgegap.com/application-management/applications/list)**.**

✅ 你现在可以继续下一步，跳到 [#test-your-server-locally](#test-your-server-locally "mention").

## ⚡ 从插件构建 <a href="#build-from-plugin" id="build-from-plugin"></a>

我们的传统插件包含高级实用工具，并且需要从源码构建 Unreal Engine。

### 准备工作 <a href="#plugin-before-starting" id="plugin-before-starting"></a>

<details>

<summary>配置你的开发环境</summary>

* [下载 Unreal Engine 源代码](https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-unreal-engine-source-code#downloadingthesourcecode).
* [设置 Visual Studio](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine).

</details>

<details>

<summary>安装官方 Edgegap Unreal Engine 插件</summary>

请选择以下官方插件之一：

* 下载 [开发者工具](/zh/unreal-engine/developer-tools.md#integration-kit),
* 或下载 [开发者工具](/zh/unreal-engine/developer-tools.md#legacy-plugin).

</details>

### 1. 配置项目 <a href="#scripts-configure-game-builds" id="scripts-configure-game-builds"></a>

☑️ [从源码构建你的 Unreal Engine 版本](https://dev.epicgames.com/documentation/en-us/unreal-engine/building-unreal-engine-from-source) 在你的开发机器上，

* 安装 [特定发布分支（例如 ](https://github.com/EpicGames/UnrealEngine/tree/5.5)[`5.5`](https://github.com/EpicGames/UnrealEngine/tree/5.5)[)](https://github.com/EpicGames/UnrealEngine/tree/5.5) 以稳定的基础进行构建，
* **使用固态硬盘（SSD）** 以加快构建速度（从约 12+ 小时缩短到约 2+ 小时），
* 这只在第一次以及每次升级 Unreal Engine 版本时需要。

{% hint style="warning" %}
**请使用 git 客户端下载分支！** 使用 GitHub 界面下载时，总是会下载不稳定的 `release` 分支。
{% endhint %}

☑️ [安装 Unreal 跨编译工具链](https://dev.epicgames.com/documentation/en-us/unreal-engine/linux-development-requirements-for-unreal-engine) 以为 Linux 构建游戏服务器。

☑️ **重启你的开发机器**，否则你之后会遇到错误！

### 2. 构建并发布 <a href="#plugin-build-and-upload-to-edgegap" id="plugin-build-and-upload-to-edgegap"></a>

☑️ **验证 Docker 已安装并正在运行。**

☑️ [重新构建我们的插件](https://dev.epicgames.com/community/learning/tutorials/qz93/unreal-engine-building-plugins) 以适配你从源码构建的自定义 Unreal Engine 版本。

☑️ **复制已编译的插件** 到你的 `Plugins` 文件夹 **在你的 Unreal 项目根目录中** （不是引擎目录）。

☑️ **从 Visual Studio 启动你新的 Unreal Engine** 并 **打开工具栏项 Edit / Plugins**.

☑️ **启用我们的插件** 在 **INSTALLED / Other**.

☑️ **配置我们的插件** 通过打开工具栏项 **Edit / Project Settings / Edgegap**:

{% hint style="warning" %}
编辑输入值后务必按回车， **以确保它们被正确保存**.
{% endhint %}

* **API Token** 上传你的服务器到 Edgegap 时需要，通过点击 Get Token 获取。
* **应用名称** Edgegap 上的名称可以与项目名相同，也可以自定义，请确保只使用小写字母、数字、连字符 `-` 和下划线 `_`.
* **Image Path** 可选地为你的 Edgegap 游戏服务器提供自定义图标，先跳过。
* **Version name** 有助于跟踪客户端/服务器兼容性，并在出现问题时回滚。
  * 使用时间戳作为应用版本名称是个不错的选择，例如 `2024.01.30-16.50.20-UTC` .
  * 多个应用版本可以指向同一个镜像标签，例如 `v1.1.0` 和 `dev` .
  * 了解更多关于 [应用与版本](/zh/learn/bian-pai/application-and-versions.md) 的信息。

{% hint style="warning" %}
**不要重复使用 `最新` 版本** 以防止我们的系统部署过时的（缓存的）镜像。
{% endhint %}

☑️ 点击 **Create Application。** 完成此步骤后将会出现一个 **新的应用** 在 [Edgegap Dashboard](https://app.edgegap.com/application-management/applications/list).

☑️ 目前先跳过自定义容器注册表设置，如果你愿意，之后可以使用第三方注册表。

☑️ 配置满意后，点击 **Build and Push**，等待流程完成，并检查你的 Unreal 控制台中是否有新的错误。完成此步骤后将会出现一个 **新文件夹** - `Saved/LinuxServer`。此外，一个 **新镜像现在会出现在你的** [仓库下方的 Edgegap Container Registry 仪表板页面中，](https://app.edgegap.com/registry-management/repositories/list)并且一个新的 [应用与版本](/zh/learn/bian-pai/application-and-versions.md#app-versions) **会出现在你的** [仪表板中应用程序下方](https://app.edgegap.com/application-management/applications/list)**.**

☑️ 在你的新应用版本中，设置环境变量 `TARGET_FILE_NAME`  以匹配你的 `DefaultServerTarget`  步骤中的值 [#id-2.-configure-game-server-builds-1](#id-2.-configure-game-server-builds-1 "mention").

✅ 你现在可以继续下一步了。

## 👉 下一步

继续到 [/pages/ac4ba735536ae20a1f8d43aa37c4ada42f5beb43#id-5.-deploy-to-cloud](https://docs.edgegap.com/zh/unreal-engine/pages/ac4ba735536ae20a1f8d43aa37c4ada42f5beb43#id-5.-deploy-to-cloud "mention") 使用我们的 [Dashboard Deployment](https://app.edgegap.com/deployment-management/deployments/list) 功能，并了解更多关于停止部署、注入变量和参数化，以及服务器可发现性的内容。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.edgegap.com/zh/unreal-engine/geng-duo-gou-jian-fang-shi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
