# 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.

- **ID:** `unity/missingreferenceexception-ui-image-sprite`
- **Domain:** unity
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Unity 2022.3.18f1 | active | — | — |
| Unity 2023.1.5f1 | active | — | — |
| Unity 2021.3.33f1 | active | — | — |

## Workarounds

1. **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).** (85% success)
   ```
   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).
   ```
2. **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.** (80% success)
   ```
   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.
   ```

## Dead Ends

- **** — 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. (70% fail)
- **** — This actually causes the problem; it destroys sprites that are still referenced. (95% fail)
- **** — Sprites are not GameObjects; DontDestroyOnLoad works on GameObjects, not assets. (90% fail)
