> 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).

# 输入管理

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

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

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

<figure><img src="/files/81e97d6b282833d12266dc628085ddb516f3947b" alt=""><figcaption></figcaption></figure>

## 如何更改对话按钮或任何输入？

1. 双击“**控制**”资源，在你的项目标签页中。<br>

   <figure><img src="/files/65db8f5808a310c7a6a771c49d7f175d133f316f" alt=""><figcaption></figcaption></figure>
2. 你可以在这里为不同设备设置多个控制方案，目前我们为 PC（键盘和鼠标）以及手柄提供了控制方案。对于移动端，我们提供了虚拟摇杆和按钮，它们在功能上映射到手柄控制，但你也可以直接添加触摸屏，并使用其不同功能来触发一个输入操作。如果你想支持其他设备，也可以点击“添加控制方案”添加自己的控制方案。

<figure><img src="/files/6070004efd52eccc8c51935d6729db5f90bf03ac" alt=""><figcaption></figcaption></figure>

3. 在上面的窗口中找到你想要更改的输入操作。如果你想添加一个新的输入操作，请参阅文档中的其他部分。在本例中，我们选择了“**对话键操作**”来更改对话按钮。点击“**T \[键盘]**”。在绑定属性窗口中，点击“ **T \[键盘]** ”按钮，位于 Path 字段中。<br>

   <figure><img src="/files/87ab91f1447479f90cc909e77cc945fa5459231c" alt=""><figcaption></figcaption></figure>
4. 按下“ **监听** ”按钮，位于打开窗口的左上角。如果你愿意，也可以从下面的分类中选择你想要的输入。

<figure><img src="/files/c5392d3e630caf5f4a700e36af67845cd73c6ba6" alt=""><figcaption></figcaption></figure>

6. 按下你想要分配的按键，它就会反映到控制资源中。

<figure><img src="/files/619885310c414b3b739f2da03d2807bc8a1aac38" alt=""><figcaption></figcaption></figure>

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

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

   <figure><img src="/files/eadc226045d42c9f701cede2fdc212a045c42d04" alt=""><figcaption></figcaption></figure>
2. 然后，点击 \<No Binding> 项为该操作设置绑定。和之前一样，你可以使用监听按钮（Windows 上有一个 UI bug，但可以正常工作），也可以从下拉菜单中选择按键。选择绑定后（这里我们将选择 \[E] 键），别忘了点击顶部菜单中的“保存资源”选项。<br>

   <figure><img src="/files/51767ef7a6740cc80ce3c2452a19a8641de3e050" alt=""><figcaption></figcaption></figure>
3. 现在你会收到一个错误，提示 ConvaiInputManager 没有实现 OnInteract。我们需要实现它。打开“ **ConvaiInputManager.cs** ”脚本来进行此操作。（“ *Convai / Scripts / Runtime / Core / ConvaiInputManager.cs* " )

   <figure><img src="/files/262f4c31d08f11b4f6b83018d12af0513e0092fe" alt=""><figcaption></figcaption></figure>
4. 你的 IDE 可能会建议你实现缺失的成员。如果没有，我们也可以像上图所示那样手动编写 OnInteract 函数。你会收到一个回调上下文，它会显示输入是在第几帧开始、执行还是被取消，你可以将其用于不同目的。就这样，错误应该已经消失了，你可以继续了！<br>

   <figure><img src="/files/f6ff306547a89d47ebb2cda373378b69db4db246" alt=""><figcaption></figcaption></figure>

   <figure><img src="/files/a3c96babe29c9fb3cf1acfdc0844344a77512d00" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/utilities/input-management.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.
