# Mirror Pong

探索如何使用来自 [Mirror 乒乓示例](https://mirror-networking.gitbook.io/docs/manual/examples/pong).

{% embed url="<https://youtu.be/bvBkObGLTMk>" %}

## ✔️ 准备工作

在开始之前，您需要：

* Unity 6 - [使用 Unity Hub 下载](https://unity.com/releases/unity-6),
* Mirror Unity 包 - [从 Unity 资源商店下载](https://assetstore.unity.com/packages/tools/network/mirror-129321),
  * 此包包含 Pong 示例。

创建一个新项目并导入上述 Mirror 包。

## ⚡ 部署并连接

### 1. 在 Edgegap 上部署服务器

☑️ 要开始，您需要 [创建一个 Edgegap 免费帐户](https://app.edgegap.com/auth/register)。无需信用卡。

☑️ [为您的应用创建一个新的应用版本](https://app.edgegap.com/application-management/applications/mirror-pong-sample/versions/create)，选择 Mirror 乒乓示例。

☑️ [使用您的 Mirror Pong 示例应用版本部署服务器](https://app.edgegap.com/deployment-management/deployments/list).

☑️ [打开您新部署的详细信息](https://app.edgegap.com/deployment-management/deployments/list).

☑️ 找到您部署的唯一一次性连接信息：

* **主机 URL** 格式为 `780aa4260e83.pr.edgegap.net` ,
* **外部端口** 格式为 `30854`  （5 位数字）。

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

### 2. 从编辑器连接

☑️ 在 Unity 中打开您的新项目。

☑️ 在文件夹 Mirror / Examples / Pong / Scenes / MirrorPong.unity 中打开场景。

☑️ 按下 ▶️ 播放 按钮以启动您的游戏客户端。

☑️ 输入来自上一步的连接详情。

☑️ 按 客户端 按钮以连接到您的服务器。

☑️ 使用第二个虚拟玩家连接， [多人游戏播放模式](https://docs-multiplayer.unity3d.com/mppm/current/about/) 或 [ParrelSync](https://github.com/VeriorPies/ParrelSync).

🙌 恭喜您完成在 Edgegap 上的首次部署！

## ✏️ 自定义服务器构建

{% hint style="success" %}
参见 [Unity](/zh/unity.md) 用于 Unity 以 **了解如何构建和自定义服务器**.
{% endhint %}


---

# 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/docs/sample-projects/unity-netcodes/mirror-pong.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.
