# 无效操作异常：ParticleSystem.CustomDataModule.SetVector：自定义数据索引1超出范围（最大2）

- **ID:** `unity/particle-system-culling-error`
- **领域:** unity
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

尝试访问的自定义数据流索引超过了ParticleSystem的CustomDataModule中启用的数量。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2022.3.5f1 | active | — | — |
| 2023.1.2f1 | active | — | — |
| 2021.3.25f1 | active | — | — |

## 解决方案

1. ```
   In Inspector, select ParticleSystem, expand CustomDataModule, ensure 'Custom1' and 'Custom2' are enabled (checkboxes). In script, use GetCustomDataModule to verify enabled streams: var cdm = ps.customData; if (cdm.enabled && cdm.GetMode(ParticleSystemCustomData.Custom1) != ParticleSystemCustomDataMode.Disabled) { cdm.SetVector(ParticleSystemCustomData.Custom1, 0, vec); }
   ```
2. ```
   Set custom data index to 0 (first stream) if only one stream is needed: cdm.SetVector(ParticleSystemCustomData.Custom1, 0, vector);
   ```

## 无效尝试

- **Increasing the index value in code** — The error is about index out of range; increasing index makes it worse. (90% 失败率)
- **Disabling CustomDataModule entirely** — Removes custom data functionality but may break intended effects. (50% 失败率)
