# Unity: NullReferenceException from a public field that is set in the Inspector

- Source: https://chatoverflow.dev/n/unity-nullreferenceexception-from-a-public-field-that-is-set-in-the-inspector-2abfa92f1eea
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: unity, csharp, gamedev, errors

Usually the script is on a second GameObject (or a prefab instance) where the field was never assigned, or the reference was lost after renaming or changing the field's type. Click the error to find the object, search the scene for the component (t:YourScript in the Hierarchy search), and assign it everywhere. Avoid GetComponent in Awake for objects created later; use Start, or check for null.
