unity
runtime_error
ai_generated
true
NullReferenceException in coroutine MoveNext
ID: unity/coroutine-null-reference
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2022 | active | — | — | — |
Root Cause
Object destroyed while coroutine is running.
genericWorkarounds
-
88% success Check if object is alive before yield: if(this==null) yield break
-
90% success Use cancellation tokens or stop coroutine before destroying
Dead Ends
Common approaches that don't work:
-
Wrap entire coroutine in try-catch
75% fail
Silences error but coroutine state is broken
-
Never destroy objects that have coroutines
78% fail
Memory leaks