# 更多构建方法

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

{% hint style="success" %}
参见 [](https://docs.edgegap.com/zh/xu-huan-yin-qing "mention") 以开始在 Edgegap 上托管 Unreal Engine 游戏服务器的第一步。
{% endhint %}

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

1. [#build-from-containers](#build-from-containers "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 注册表](https://app.edgegap.com/registry-management/repositories/list) 用于上传已完成构建的凭据。

☑️ **执行已编辑的脚本** 以开始构建和上传过程。完成此步骤将在你的 **Edgegap 容器注册表仪表板页面的** [仓库中添加一个新的](https://app.edgegap.com/registry-management/repositories/list).

☑️ 你将被自动重定向到 **创建一个新的** [#app-versions](https://docs.edgegap.com/zh/learn/bian-pai/application-and-versions#app-versions "mention") 在 [仪表板](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>

选择以下官方插件之一：

* 下载 [#integration-kit](https://docs.edgegap.com/zh/developer-tools#integration-kit "mention"),
* 或下载 [#legacy-plugin](https://docs.edgegap.com/zh/developer-tools#legacy-plugin "mention").

</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 UI 将始终下载不稳定的 `发布` 分支。
{% 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** 并 **打开工具栏项 编辑 / 插件**.

☑️ **在** 已安装 / 其他 **部分启用我们的插件**.

☑️ **配置我们的插件** 通过打开工具栏项 **编辑 / 项目设置 / Edgegap**:

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

* **API 令牌** 用于将你的服务器上传到 Edgegap，可通过点击 获取令牌 来获取。
* **应用名称** 在 Edgegap 上可以与项目名称相同或自定义，确保只使用小写字母、数字、连字符 `-` 和下划线 `_`.
* **图像路径** 可为你的 Edgegap 游戏服务器可选提供自定义图标，暂时可跳过。
* **版本名称** 对于跟踪客户端/服务器兼容性以及在出现问题时回滚非常有用。
  * 时间戳是应用版本名称的一个很好的选项，例如： `2024.01.30-16.50.20-UTC` .
  * 多个应用版本可以指向相同的镜像标签，例如 `v1.1.0` 和 `dev` .
  * 稍后了解更多关于 [application-and-versions](https://docs.edgegap.com/zh/learn/bian-pai/application-and-versions "mention") 的信息。

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

☑️ 点击 **创建应用。** 完成此步骤将导致一个 **新的应用出现在** 在 [Edgegap 仪表板](https://app.edgegap.com/application-management/applications/list).

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

☑️ 一旦你对配置满意，点击 **构建并推送**，等待过程完成并确认你的 Unreal 控制台中没有新的错误。完成此步骤将导致一个 **新的文件夹出现在你的项目根目录中** - `Saved/LinuxServer`。此外， **现在在你的** [Edgegap 容器注册表仪表板页面的仓库下出现一个](https://app.edgegap.com/registry-management/repositories/list)新的镜像， [#app-versions](https://docs.edgegap.com/zh/learn/bian-pai/application-and-versions#app-versions "mention") **并且在你的** [仪表板应用下出现一个](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").

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

## 👉 后续步骤

继续到 [#id-5.-deploy-to-cloud](https://docs.edgegap.com/zh/xu-huan-yin-qing/..#id-5.-deploy-to-cloud "mention") 使用我们的 [仪表板部署](https://app.edgegap.com/deployment-management/deployments/list) 功能，了解更多关于停止部署、注入变量与参数化以及服务器可发现性的信息。


---

# Agent Instructions: 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/xu-huan-yin-qing/geng-duo-gou-jian-fang-fa.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.
