# 无效操作异常：无法将不可靠消息入队。不可靠消息队列已满。

- **ID:** `unity/network-unreliable-message-queue-full`
- **领域:** unity
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

网络传输层的不可靠消息队列已达到容量上限，通常是由于发送了过多不可靠消息而未处理，或网络缓冲区泄漏。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2022.3.15f1 | active | — | — |
| Unity 2023.2.0b5 | active | — | — |
| Netcode for GameObjects 1.6.0 | active | — | — |

## 解决方案

1. ```
   通过实现发送速率限制器来降低不可靠消息的频率。例如，在脚本中使用计时器，每秒最多发送 10 条消息：`if (Time.time - lastSendTime > 0.1f) { SendUnreliableMessage(); lastSendTime = Time.time; }`。
   ```
2. ```
   在网络传输配置中增加不可靠消息队列大小（例如在 Unity Transport 中，将 `maxUnreliableQueueSize` 设置为更高的值，如 1024）。
   ```
3. ```
   监控并记录传出消息数量，以识别并修复在 Update() 中无意发送消息的脚本。
   ```

## 无效尝试

- **** — Increasing the queue size without addressing the root cause (e.g., message spam) may only delay the error and cause memory issues. (70% 失败率)
- **** — Restarting the game client clears the queue temporarily but does not fix the underlying excessive message generation. (90% 失败率)
