> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/building-for-supported-platforms/building-for-vr.md).

# 为 VR 构建

为 VR 构建——用于使用 Convai 进行 VR 开发的 Unity 插件指南。

## VR 安装

如果你想让你的 Convai 插件兼容 VR，可以通过自动或手动流程来实现。请查看下面的说明，或者看看我们的 [*最新教程视频*](https://www.youtube.com/watch?v=Q0TUT5vtEyg) ，在 YouTube 上。

{% embed url="<https://www.youtube.com/watch?v=Q0TUT5vtEyg>" %}
在你的 Unity VR 游戏中释放 Convai AI NPC 的强大力量
{% endembed %}

### 方法 1：自动设置

{% hint style="success" %}
推荐用于新项目。
{% endhint %}

{% hint style="danger" %}
将执行以下流程：

* 通用渲染管线（URP）
* OpenXR 插件
* XR 交互工具包
* Convai 自定义 VR 包
* Convai URP 转换器

**如果这些包不存在，它们将被安装。**
{% endhint %}

{% hint style="danger" %}
**如果目标构建平台不是 Android，它将切换为&#x20;*****Android。***
{% endhint %}

{% hint style="warning" %}
请确保从 Unity Hub 下载与你项目版本对应的 Android 平台支持。
{% endhint %}

1. 点击“ *Convai / Convai 自定义包安装器 / 安装 VR 包* "

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FdhMwvXFD57kiUB6Jakcd%2FConvaiCustomPackageInstaller.png?alt=media&amp;token=f648e25f-a7a7-4e67-b94b-fc395267d99e" alt=""><figcaption></figcaption></figure>

2. 确认将进行的更改和流程。如果你同意，流程将开始。点击“ **是，继续** ”，流程将开始。你会在控制台中看到日志。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FGy6nnyA0L2vgaXXLQkF9%2FConvaiCustomPackageInstallerConfirmWindow.png?alt=media&amp;token=2ae378ec-0aac-4b34-b377-6db86af7b013" alt=""><figcaption></figcaption></figure>

3. 如果你遇到类似“Failed to Resolve Packages”的错误，不用担心。流程会继续，并且在包安装完成后，该错误会自动解决。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FPfhlasAaDsBnTIckCmct%2FVRLogs.png?alt=media&amp;token=8dff5c2d-7331-4815-9254-34022be73dd3" alt=""><figcaption></figcaption></figure>

4. 打开“ *Convai / Scenes / Convai Demo - VR* ”演示场景。如果出现 TMP 导入器窗口，请点击“ **导入 TMP 基础资源** ”来为 UI 文本对象安装 TextMeshPro。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F69nbgYYrti9eBL9Ogfbo%2FAutomaticallyImportTMPEssentials.png?alt=media&amp;token=31bdc58f-c282-4d6d-88db-8ff7ae9a1045" alt=""><figcaption></figcaption></figure>

或者，你也可以使用“ *窗口 / TextMeshPro / 导入 TMP 基础资源* ”来安装它。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F22hL0PzDtgfJUMUbapkX%2FManualImportTMPEssentialsResources.png?alt=media&amp;token=2fee2d5c-8622-419b-8069-6d7a643c6930" alt=""><figcaption></figcaption></figure>

5. 通过前往“来构建你的项目： *文件 / 构建设置 / 构建* ”。确保“ **Convai Demo - VR** ”场景包含在 Scenes in Build 部分中。

现在一切都已准备好，可以进行测试了。🙂✅

{% hint style="warning" %}
请确保你已设置 API 密钥。（Convai / Convai 设置）
{% endhint %}

### 方法 2：手动设置

{% hint style="danger" %}
确保你的项目中已安装以下包：

* OpenXR 或 Oculus XR
* XR 交互工具包
* URP（通用渲染管线）
  {% endhint %}

1. 双击“ *Convai / Convai 自定义 Unity 包 / ConvaiVRUpgrader.unitypackage* "

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FJi7Q2eCxi2i4rV46woxo%2FConvaiVRUpgrader.png?alt=media&amp;token=48c6c18c-0d43-479d-9979-e543c4ad29dc" alt=""><figcaption></figcaption></figure>

2. 你会看到一条警告，提示这些设置将覆盖你的项目设置。你可以通过点击“ **导入** ”来允许，或者通过点击“ **切换项目** "

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FJ4ZKKrM5HTCwo1Jtam9i%2FVRUpgraderWarning.png?alt=media&amp;token=b176d06d-f75b-47b6-90cb-6ca779e527a2" alt=""><figcaption></figcaption></figure>

3. 在导入 Unity 包窗口中，检查将要导入的资源，然后点击“ **下一步** "

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Fl5JBO61zZxrz5i3T907b%2FConvaiVRUpgraderimport_1.png?alt=media&amp;token=3275b9f6-bb6e-4b4d-88ba-2104a944b701" alt=""><figcaption></figcaption></figure>

4. 在此窗口中，选择你要导入的项目设置，并通过点击“完成安装 **导入** ".

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FRqtZy5z75gbM84isPgGw%2FConvaiVRUpgraderimport_2.png?alt=media&amp;token=5d3ecc1f-d515-402e-a4ac-92711fbadb1d" alt=""><figcaption></figcaption></figure>

5. 打开“ *Convai / Scenes/ Convai Demo - VR* ”演示场景。如果出现 TMP 导入器窗口，请点击“ **导入 TMP 基础资源** ”来为 UI 文本对象安装 TextMeshPro。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F69nbgYYrti9eBL9Ogfbo%2FAutomaticallyImportTMPEssentials.png?alt=media&amp;token=31bdc58f-c282-4d6d-88db-8ff7ae9a1045" alt=""><figcaption></figcaption></figure>

6. 如果你看到 3D 对象呈粉色，那是着色器问题。如果你正在使用 URP，请通过双击“将材质转换为 URP *Convai / Convai 自定义 Unity 包 / ConvaiURPConverter* ”并导入出现的窗口中的所有资源。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FR9jINUQqbrd9jZp4SCYV%2FConvaiURPConverter.png?alt=media&amp;token=25651447-64c9-44d4-890b-0ab8823609eb" alt=""><figcaption></figcaption></figure>

7. 通过前往“来构建你的项目： *文件 / 构建设置 / 构建* ”。确保“ **Convai Demo - VR** ”场景已包含在 Scenes in **构建** 部分。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Feu0juFyPC3bTreRVgyJl%2FVRBuildSettings.png?alt=media&amp;token=7207776e-65a8-45d8-93cc-a60502a88c9d" alt=""><figcaption></figcaption></figure>

现在一切都已准备好，可以进行测试了。🙂✅

{% hint style="warning" %}
请确保你已设置 API 密钥（Convai/Convai 设置）。
{% endhint %}

### Convai 默认 VR 控制器方案

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Fzfuv4O5hF4aCq6kOdvl7%2FConvaiDefaultVRControllerScheme.png?alt=media&amp;token=8d9a747a-cfd5-4592-9cce-dc5bac90aeea" alt=""><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/building-for-supported-platforms/building-for-vr.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
