> 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/utilities/input-management.md).

# 输入管理

输入管理——高效处理 Convai Unity 插件集成的输入。

{% hint style="success" %}
请确保 **活动输入处理** 在

"*项目设置 > 玩家*”设置为 **两者** 或 **输入系统包（新版）**.

我们建议选择“两者”。这样，您就可以同时使用新旧输入系统。创建用于测试的输入时，使用旧输入系统可能会更快。
{% endhint %}

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FnHEugBtAH65h5nobDNAa%2FActiveInputHandling.png?alt=media&amp;token=426248d4-f818-4571-94d8-c988ca635053" alt=""><figcaption></figcaption></figure>

## 如何更改交谈按钮或其他输入？

1. 在项目面板中双击“**控制**”资源。<br>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F27EF3Exxk63iQGvuIuWY%2Fimage.png?alt=media&amp;token=ea1bd3ee-3d98-40c3-8df6-0f78b2ce15bc" alt=""><figcaption></figcaption></figure>
2. 您可以在此为不同设备设置多种控制方案。目前我们提供了 PC（键盘和鼠标）以及游戏手柄的方案。对于移动设备，我们提供了摇杆和按钮，它们映射到游戏手柄控制项以实现相应功能；不过，您也可以直接添加触摸屏，并使用其不同功能来触发输入操作。如果要支持其他设备，还可以点击“添加控制方案”来添加自己的控制方案。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Fk4BWLFrgSN3kLiWFk6Nw%2Fimage.png?alt=media&amp;token=d161daa8-bbc8-4330-ad1e-4476f4f84f47" alt=""><figcaption></figcaption></figure>

3. 在上方窗口中找到您要更改的输入操作。如果要添加新的输入操作，请参阅文档中的其他章节。在本例中，我们选择“**交谈按键操作**”来更改交谈按钮。点击“**T \[键盘]**”。在“绑定属性”窗口中，点击路径字段里的“ **T \[键盘]** ”按钮。<br>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FXntfJHlsNoAYi7eH725N%2Fimage.png?alt=media&amp;token=733b241a-0fa9-4b32-90a3-da572c898ba2" 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%2FT2h3hum3nvVmi5D6V1Mv%2FPressListenButton.png?alt=media&amp;token=fff80f2a-948a-4050-8f07-8a14bfbfe1c8" alt=""><figcaption></figcaption></figure>

6. 按下要分配的按键，该按键就会显示在控制资源中。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FAGkirDWUoCxluysgUalM%2FPressKey.png?alt=media&amp;token=7689ea3a-52fc-4799-9136-5c249b2f986e" alt=""><figcaption></figcaption></figure>

## 如何添加新的输入操作？

1. 首先，转到上文提到的控制资源，并使用添加按钮创建一个输入操作。在本例中，我们将其命名为 interact，并将 \[E] 按键设为其绑定。<br>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FzVLxZpn6nk52W8uhDBWz%2Fimage.png?alt=media&amp;token=91364302-d110-4c46-8151-7aa45421b807" alt=""><figcaption></figcaption></figure>
2. 然后，点击 \<No Binding> 项，为此操作设置绑定。与之前一样，您可以使用“监听”按钮（该按钮在 Windows 上存在 UI 错误，但仍可正常使用），也可以从下拉菜单中选择按键。选择绑定后（本例中我们选择 \[E] 键），别忘了点击顶部菜单中的“保存资源”选项。<br>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FXjOG9y4DBQsMnBLwoBSF%2Fimage.png?alt=media&amp;token=9d888b26-b210-46f7-ae63-78522b8515e8" alt=""><figcaption></figcaption></figure>
3. 现在会出现一条错误，提示 ConvaiInputManager 未实现 OnInteract。我们需要实现此方法。打开“ **ConvaiInputManager.cs** ”脚本进行设置。（“ *Convai / Scripts / Runtime / Core / ConvaiInputManager.cs* " )

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Fx24yDyHnk1IT7WLhoFDs%2Fimage.png?alt=media&amp;token=3658cb39-481f-47bc-84f0-a887453634a1" alt=""><figcaption></figcaption></figure>
4. 您的 IDE 可能会建议您实现缺失的成员。如果没有，也可以像最后一张图中那样手动编写 OnInteract 函数。您会收到一个回调上下文，其中会显示输入开始、执行或取消时所处的帧，您可以将其用于不同用途。完成后，错误就会消失，一切就绪！<br>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FlkrdGVTlBkBd1F1j1TIV%2Fimage.png?alt=media&amp;token=7121bdc4-e26e-47d1-aaa9-3008d9986693" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2Ffw02nx8EWBkmOlJakAIN%2Fimage.png?alt=media&amp;token=fd5fdf7a-a9a4-4b16-a000-9581d2d296b9" 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/utilities/input-management.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.
