{
  "id": "unity/tilemap-cell-position-out-of-bounds",
  "signature": "ArgumentException: Tilemap position (x, y) is out of bounds. Valid range is (0, 0) to (width-1, height-1).",
  "signature_zh": "ArgumentException：Tilemap 位置 (x, y) 超出边界。有效范围为 (0, 0) 到 (width-1, height-1)。",
  "regex": "ArgumentException: Tilemap position \\(\\d+, \\d+\\) is out of bounds\\.",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to set or get a tile at a position outside the Tilemap's defined bounds, often due to incorrect loop boundaries or dynamic resizing.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在 Tilemap 定义边界之外的位置设置或获取瓦片，通常是由于循环边界错误或动态调整大小。",
  "versions": [
    {
      "version": "Unity 2020.3.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2021.3.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2022.3.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.2.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually resize the Tilemap in the Inspector by changing cell bounds",
      "why_fails": "Resizing may not account for all tiles placed at edges; the error occurs at runtime due to code logic, not bounds settings.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrap the call in a try-catch to ignore the error",
      "why_fails": "This hides the symptom but does not prevent invalid positions, potentially corrupting tile data.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check bounds before accessing: if (tilemap.cellBounds.Contains(new Vector3Int(x, y, 0))) { tilemap.SetTile(new Vector3Int(x, y, 0), tile); }",
      "success_rate": 0.9,
      "how": "Check bounds before accessing: if (tilemap.cellBounds.Contains(new Vector3Int(x, y, 0))) { tilemap.SetTile(new Vector3Int(x, y, 0), tile); }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use tilemap.HasTile(x, y) to verify existence before operations: if (tilemap.HasTile(new Vector3Int(x, y, 0))) { // proceed }",
      "success_rate": 0.85,
      "how": "Use tilemap.HasTile(x, y) to verify existence before operations: if (tilemap.HasTile(new Vector3Int(x, y, 0))) { // proceed }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check bounds before accessing: if (tilemap.cellBounds.Contains(new Vector3Int(x, y, 0))) { tilemap.SetTile(new Vector3Int(x, y, 0), tile); }",
    "Use tilemap.HasTile(x, y) to verify existence before operations: if (tilemap.HasTile(new Vector3Int(x, y, 0))) { // proceed }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/Manual/class-Tilemap.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-04-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}