# Unity 对话系统

Unity 的 Dialogue System 是一个用于 Unity 的分支对话系统。它无需脚本即可使用，但设计上易于程序员扩展，已被用于《Disco Elysium》、《Yes Your Grace Snowfall》等多款游戏。

<a href="https://prf.hn/l/7JOjQmj/" class="button primary">获取 Unity 的 Dialogue System</a> *（推广链接）*

***

## 集成步骤

{% hint style="info" %}
我们已在 Dialogue System for Unity 版本下测试过 Text Animator 3.X **2.2.64.1**

它应适用于 Dialogue System 2.X 的所有版本，但如果你发现引入了某些破坏性更改——请告知我们！
{% endhint %}

所有集成步骤同时写在此处和 PixelCrushers 的文档中。

{% embed url="<https://www.pixelcrushers.com/dialogue_system/manual2x/html/text_animator.html>" %}

你可以通过一个 [简短视频](#video-guide) 或通过 [文字指南](#text-guide) 来学习，详见下文。

### 视频指南

{% embed url="<https://3857371675-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2Fff258LTw3nvqQgNfDjpp%2FTutorial%20Integration%20Dialogue%20System%20with%20Text%20Animator%203.mp4?alt=media&token=bd08b49b-1550-4996-942f-fe7be8f1aeaa>" %}

### 文字指南

{% stepper %}
{% step %}

#### 项目设置

**步骤 1。** 确保在 Dialogue System for Unity 中启用了 TextMeshPro

<figure><img src="https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2Fm2SveaTFBG0i5J5b4XZv%2Fimage.png?alt=media&#x26;token=52de6122-aa2b-465c-83e8-f01f3a12e7a9" alt=""><figcaption></figcaption></figure>

*（Text Animator 使用 TMPro 或 UI Toolkit，因此你可以选择最喜欢的一个，两个的设置类似）*

**步骤 2。** 从 Dialogue System -> Third Party support 导入 “Text Animator V3” 支持包。

<figure><img src="https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2FzS01Ns1TvaSY7woaRAvZ%2Fimage.png?alt=media&#x26;token=607d8cb3-318d-49d5-92fd-911482c423c1" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### 文本设置

对于你想要为其添加动画的对话预制件中的每个文本元素（例如 NPC 字幕）：

* 确保基础文本组件为 `TextMeshPro` （并确保在 UI 面板中重新链接任何断开的引用）。<br>

  <figure><img src="https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2FVYtLFkyMo4dL1az9mDQZ%2Fimage.png?alt=media&#x26;token=d7907b06-326a-4091-be8f-38100faeda6d" alt=""><figcaption></figcaption></figure>
* 添加一个 `Text Animator` 组件到相同的文本游戏对象上。
* 另外添加一个 `Typewriter` 组件（如果你想使用打字机效果）。
  {% endstep %}

{% step %}

#### 替换标准 UI 字幕面板&#x20;

将 `标准 UI 字幕面板` 替换为 `Text Animator 字幕面板` 并确保所有引用都是最新的。&#x20;

<figure><img src="https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2Fid37170j6LLXDZvJvph0%2Fimage.png?alt=media&#x26;token=7b84f40e-693f-4203-b0bd-585b446e5a4b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
与其手动删除并重新添加组件（这可能会破坏现有引用），你可以使用检查器右上角的调试模式（顶点的点）更轻松地替换脚本。

![](https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2FZHp1I0muPHUi5Ptfh4m8%2Fimage.png?alt=media\&token=74685410-140d-4405-b689-6df404c9fad4)
{% endhint %}
{% endstep %}

{% step %}

#### 替换继续按钮

将 `将标准 UI 继续按钮` 替换为专为 `Text Animator` 由 PixelCrushers 设计、称为 `Text Animator Continue Button 快速前进`.

还要确保在检查器中正确链接了 Typewriter 组件。

<figure><img src="https://1326131491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuXUTa2X5PYuYL6yRvl1%2Fuploads%2F3RzwkJ7vFATbVRDzoLOA%2Fimage.png?alt=media&#x26;token=b6a8f674-dab3-45e8-b0ae-ee3c11d4054f" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

***

尽情享用！查看 [ru-he-tian-jia-xiao-guo](https://docs.febucci.com/text-animator-unity/3.x-zh/xiao-guo/ru-he-tian-jia-xiao-guo "mention") 和 [dong-tai-xian-shi-he-yin-cang-zi-mu](https://docs.febucci.com/text-animator-unity/3.x-zh/da-zi-ji/dong-tai-xian-shi-he-yin-cang-zi-mu "mention") 以快速开始为你的对话添加更多效果。
