unity
config_error
ai_generated
true
参数异常:TilemapCollider2D:无效的边界。瓦片地图边界为空。
ArgumentException: TilemapCollider2D: Invalid bounds. The tilemap bounds are empty.
ID: unity/tilemap-collider-invalid-bounds
90%修复率
85%置信度
1证据数
2023-09-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Unity 2022.3.5f1 | active | — | — | — |
| Unity 2023.2.0b2 | active | — | — | — |
根因分析
TilemapCollider2D 组件添加到了没有放置任何瓦片的瓦片地图上,导致碰撞体计算出空边界。
English
A TilemapCollider2D component is added to a Tilemap that has no tiles placed, causing the collider to compute empty bounds.
官方文档
https://docs.unity3d.com/Manual/class-TilemapCollider2D.html解决方案
-
使用瓦片调色板或脚本在瓦片地图上至少放置一个瓦片:`tilemap.SetTile(new Vector3Int(0, 0, 0), yourTile);`。
-
如果瓦片地图应为空,则移除 TilemapCollider2D 组件,或使用 CompositeCollider2D 配合独立的碰撞体设置。
无效尝试
常见但无效的做法:
-
80% 失败
Disabling and re-enabling the collider does not fix the empty bounds; the collider still has no tiles to compute from.
-
90% 失败
Setting the Tilemap's cell size to zero or negative values may cause other errors but not resolve the empty bounds.