{
  "id": "unity/missingreferenceexception-ui-image-sprite",
  "signature": "MissingReferenceException: The sprite 'ui_button_bg' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.",
  "signature_zh": "MissingReferenceException：精灵 'ui_button_bg' 已被销毁，但你仍在尝试访问它。你的脚本应检查它是否为空，或者你不应销毁该对象。",
  "regex": "MissingReferenceException: The sprite '.+' has been destroyed but you are still trying to access it",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A UI Image component's sprite reference points to a Sprite object that was destroyed (e.g., via Resources.UnloadUnusedAssets or scene unloading) while the Image still exists.",
  "root_cause_type": "generic",
  "root_cause_zh": "UI Image 组件的精灵引用指向了一个已被销毁的 Sprite 对象（例如通过 Resources.UnloadUnusedAssets 或场景卸载），而 Image 仍然存在。",
  "versions": [
    {
      "version": "Unity 2022.3.18f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.1.5f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2021.3.33f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The sprite reference is lost at runtime due to destruction, not because it was never assigned. Setting null prevents the error but breaks UI functionality.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This actually causes the problem; it destroys sprites that are still referenced.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sprites are not GameObjects; DontDestroyOnLoad works on GameObjects, not assets.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Before accessing the sprite, check if the Image component's sprite is null and reassign it from a persistent source (e.g., Resources.Load or Addressables).",
      "success_rate": 0.85,
      "how": "Before accessing the sprite, check if the Image component's sprite is null and reassign it from a persistent source (e.g., Resources.Load or Addressables).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the sprite asset is marked as 'Keep' in the Addressables system or is included in a preloaded asset bundle to prevent it from being unloaded.",
      "success_rate": 0.8,
      "how": "Ensure the sprite asset is marked as 'Keep' in the Addressables system or is included in a preloaded asset bundle to prevent it from being unloaded.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Before accessing the sprite, check if the Image component's sprite is null and reassign it from a persistent source (e.g., Resources.Load or Addressables).",
    "Ensure the sprite asset is marked as 'Keep' in the Addressables system or is included in a preloaded asset bundle to prevent it from being unloaded."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/ScriptReference/MissingReferenceException.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-09-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}