# 序列化深度限制已超出。考虑在项目设置中增加序列化深度限制。

- **ID:** `unity/scriptableobject-serialization-layout-change`
- **领域:** unity
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

ScriptableObject 或 MonoBehaviour 具有深度嵌套的引用链（超过 7 层），超出 Unity 的默认序列化深度。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2022.3 | active | — | — |
| Unity 2023.2 | active | — | — |
| Unity 2021.3 | active | — | — |

## 解决方案

1. ```
   Restructure your data to avoid deep nesting: flatten references by using IDs or asset references instead of direct object references. Example: replace `public List<ChildData> children;` with `public List<string> childGuids;` and load via Resources.Load.
   ```
2. ```
   Increase the serialization depth limit in Edit > Project Settings > Editor > Serialization Depth Limit to a higher value (e.g., 10 or 15).
   ```
3. ```
   Use `[System.NonSerialized]` on intermediate fields that don't need to persist, breaking the serialization chain.
   ```

## 无效尝试

- **** — Simply increasing the depth limit in Project Settings can mask the issue and lead to performance degradation from deep serialization. (30% 失败率)
- **** — Adding [SerializeReference] to fields does not reduce the depth; it only changes how references are stored. (50% 失败率)
- **** — Removing all nested objects breaks the data structure and loses functionality. (70% 失败率)
